I’m getting the above error with Rails 3.1.1 and Ruby 1.9.2. I’ve spent the last hour looking and the main things I’ve found were:
-
clear_helpersin ApplicationController can cause the helpers to not load. My code isn’t using that and I don’t believe the gems I’ve installed are either. -
Missing
devise_forin routes.rb. I havedevise_for :users -
Missing ‘database_authenticatable’ in my Users model. I have in my users.rb :
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable -
My behavior matches exactly what’s described in this email thread except
signed_in? :userdoesn’t work for me either. However,Devise.mappingsdoes show the user mapping.
Any ideas on what could be wrong? Even a hack for current_user would help me greatly as I have to get some functionality running ASAP.
So I’m marking this as a community wiki since the solution is trivial.
I was calling debugger (which I used to check
current_userwith the following codeRails makes the session and request objects available to instances of controllers. That debugger is called in the context of
self == ApplicationControllerwhen it should beself == #<MainController...>.Long story short, make sure you’re not trying to call it within a controller definition but within the controller instance.