2
votes

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:

  1. clear_helpers in 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.

  2. Missing devise_for in routes.rb. I have devise_for :users

  3. Missing 'database_authenticatable' in my Users model. I have in my users.rb :

    devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

  4. My behavior matches exactly what's described in this email thread except signed_in? :user doesn't work for me either. However, Devise.mappings does 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.

2

2 Answers

1
votes

Number 3 strikes me as odd. Is your model file named users.rb? Is your class declaration Users < ActiveRecord::Base? If so, change them to the below.

users.rb => user.rb

User < ActiveRecord::Base

1
votes

So I'm marking this as a community wiki since the solution is trivial.

I was calling debugger (which I used to check current_user with the following code

class ApplicationController < ActionController::Base
  protect_from_forgery
  debugger
  filter {|c| Authorization.current_user = c.current_user}
end

Rails makes the session and request objects available to instances of controllers. That debugger is called in the context of self == ApplicationController when it should be self == #<MainController...>.

Long story short, make sure you're not trying to call it within a controller definition but within the controller instance.