Can’t figure out what’s wrong here. Followed Devise setup instructions, Googled everything I can think of, still no luck.
undefined method `email' for #<User id: nil, created_at: nil, updated_at: nil>
Extracted source (around line #7):
4: <%= devise_error_messages! %>
5:
6: <div><%= f.label :email %><br />
7: <%= f.email_field :email %></div>
8:
9: <div><%= f.label :password %><br />
10: <%= f.password_field :password %></div>
Here’s my user model:
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
validates_presence_of :email
validates_uniqueness_of :email, :case_sensitive => false
end
I’ve run rake db:migrate, reset the server, what have you. Still can’t figure out where I’m going wrong. I’ve even got another basic app with the same setup, combing through the source it seems like I’ve done everything correctly, just can’t see the problem.
Basically your error means you don’t have an
emailcolumn (or attr_accessor) in your User model.I guess you used Devise < 2.0 and now you use the latest version.
Since 2.0, Devise doesn’t include the columns automatically to your model anymore, see this page for more info.