Wednesday, February 23, 2011

Getting error: undefined method `to_key' for #

Rails 3 and Authlogic together giving error :
undefined method `to_key' for #<UserSession: no credentials provided>
To fix the error, change the code in user_session.rb as given below:

class UserSession < Authlogic::Session::Base

 def to_key
   new_record? ? nil : [ self.send(self.class.primary_key) ]
  end
end

And it will work fine.
For details, you can refer to http://techoctave.com/c7/posts/37-authlogic-and-rails-3-0-solution

1 comment: