5

Devise is throwing an issue I don't understand.

Using better errors gem; here's where it gets caught:

block in constantize(gem) activesupport-3.2.12/lib/active_support/inflector/methods.rb

  225         names = camel_cased_word.split('::')
  226         names.shift if names.empty? || names.first.empty?
  227 
  228         constant = Object
  229         names.each do |name|
  230           constant = constant.const_defined?(name, false) ? 
                  constant.const_get(name) : constant.const_missing(name)
  231         end
  232         constant
  233       end
  234     end 

Further details:

Request info:
Request parameters {"controller"=>"devise/sessions", "action"=>"new"}
Rack session       {"session_id"=>"a2bcc708204fb5dce015439f6881f67d","_csrf_token"=>"TzIKUgPy8y4F6kFfkDG/xfgCm4vMqkgReLHbK+cjeFI=", "warden.user.user.key"=>[[17], "$2a$10$/WvxkLxIdgHOMxg8nus6cu"]}


Local Variables:
name      [17]
camel_cased_word [17]
names    [[17]]
constant Object

Any ideas? What further info would be useful?

Here's a chunk off the end of the trace:

block in ActiveSupport::Inflector.constantize
(gem) activesupport-3.2.12/lib/active_support/inflector/methods.rb, line 230
ActiveSupport::Inflector.constantize
(gem) activesupport-3.2.12/lib/active_support/inflector/methods.rb, line 229
Warden::SessionSerializer#deserialize
(gem) devise-2.2.3/lib/devise/rails/warden_compat.rb, line 27
Warden::SessionSerializer#fetch
(gem) warden-1.2.1/lib/warden/session_serializer.rb, line 35
Warden::Proxy#user
(gem) warden-1.2.1/lib/warden/proxy.rb, line 212
Warden::Proxy#_perform_authentication
(gem) warden-1.2.1/lib/warden/proxy.rb, line 318
Warden::Proxy#authenticate
(gem) warden-1.2.1/lib/warden/proxy.rb, line 104
Warden::Proxy#authenticate?
(gem) warden-1.2.1/lib/warden/proxy.rb, line 114
Devise::SessionsController#require_no_authentication
(gem) devise-2.2.3/app/controllers/devise_controller.rb, line 124
Devise::SessionsController#
_run__642094268016367352__process_action__582726832569976772__callbacks
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb, line 418
Devise::SessionsController.__run_callback
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb, line 405
Devise::SessionsController#_run_process_action_callbacks
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb, line 385
Devise::SessionsController#run_callbacks
(gem) activesupport-3.2.12/lib/active_support/callbacks.rb, line 81
Devise::SessionsController#process_action
(gem) actionpack-3.2.12/lib/abstract_controller/callbacks.rb, line 17
Devise::SessionsController#process_action
(gem) actionpack-3.2.12/lib/action_controller/metal/rescue.rb, line 29
block in Devise::SessionsController#process_action
(gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb, line 30
block in ActiveSupport::Notifications.instrument
(gem) activesupport-3.2.12/lib/active_support/notifications.rb, line 123
ActiveSupport::Notifications::Instrumenter#instrument
(gem) activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb, line 20
ActiveSupport::Notifications.instrument
(gem) activesupport-3.2.12/lib/active_support/notifications.rb, line 123
Devise::SessionsController#process_action
(gem) actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb, line 29
Devise::SessionsController#process_action
Someone Else
  • 321
  • 2
  • 11
  • 2
    Did you just upgrade Devise? If so, from- and to- what version? – rossta Apr 08 '13 at 03:58
  • 1
    Yes and no. Earlier I had simply linked directly to the repo with: `gem 'devise', :git => 'git://github.com/plataformatec/devise.git'`. I added this back in my gemfile and it seems to have resolved the problem. Thanks very much. What led you to assume I had upgraded, however? – Someone Else Apr 08 '13 at 04:08
  • 3
    It was a guess considering you were getting the error while deserializing your session data. If the code to serialize/deserialize changes, as it could in a devise up/downgrade, you'd see errors deserializing previously existing sessions. – rossta Apr 08 '13 at 12:36

2 Answers2

3

I updated from 2.0.4 to 2.2.4 and that happened me when I changed to a stable branch of my project with the old version. The solution was to clear all the cookies in the browser for my localhost. In your case would be the server where you're running your application.

Alter Lagos
  • 12,090
  • 1
  • 70
  • 92
0

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.

user3294438
  • 371
  • 3
  • 5