undefined method `authenticate?'

If you are getting this error:

ActionView::Template::Error: undefined method `authenticate?' for nil:NilClass

in your call to Devise’s user_signed_in? or similar, you probably forgot to add this:

class ActionController::TestCase
  include Devise::TestHelpers
end

at the bottom of the test_helper.rb file. Not that that would ever happen to me…

Advertisements

4 Replies to “undefined method `authenticate?'”

  1. Thank you! Apparently, Ruby class declarations are additive. The ActionController::TestCase class is declared in both the actionpack gem and your app’s test_helper.rb. However, both declarations are put together to form the class implementation as opposed to some languages where an error would occur at compile or interpretation time due to ambiguous redeclaration.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s