I recently ran a bundle update and now I am getting a weird
Type - [17] is not a symbol error.
This is the full error message:
The question was posted a long time ago so I suppose the original person doesn't need the answer anymore. But there might be people like me who is in desperate need for an answer other than blowing up all sesssions. Here's the cause and my solution: Devise 2.2.4 has backward incompatible changes that breaks all existing session. See the change log for 2.2.4 https://github.com/plataformatec/devise/blob/master/CHANGELOG.md
Sessions created by devise >=2.2.4 cannot be correctly handled by devise <=2.2.3.
The problem comes from the session keys devise used. Let's say you have devise on your Player model. For devise<=2.2.3, the session has the following in the session
session["warden.user.player.key']=["Player", [player_id], "somehashhere"]
For devise>=2.2.4, the session becomes the following
session["warden.user.player.key']=[[player_id], "somehashhere"]
I suppose the devise author don't like the "Player" as it's already specified in a lot of different places as well as the key itself. It's a reasonable change and the new code does handle the upgrade correctly as it can understand the old sessions and keeps your outstanding sessions alive.
But that only solves the problem for upgrade, not downgrade. If you upgrade your devise to 2.2.4, log in and then downgrade to 2.2.3, you will see an error like this. Apparently somewhere in devise code (<2.2.3) it converts the 'Play' into symbol :user. But the 'User' is not there anymore and you got a 'not a symbol' error.
Devise page points to a solution only if you use db storage for session. You would need a migration for that https://gist.github.com/moll/6417606
If you use cookie store storage (rails default for a long time), then you need to add the following code to application controller when you downgrade from later version of devise
before_filter :fix_session
def fix_session
key = session["warden.user.player.key"]
if key && key.is_a?(Array) && key[0].is_a?(Array)
session["warden.user.player.key"].unshift('Player')
end
end
As for why downgrading? If you are sure that everything works and you will never have to rollback then it's not an issue. But if you are not so sure, you will need this.