Devise undefined method `email'-Collection of common programming errors

Whenever I hit the sign in button I get the following error:

NoMethodError in Devise/sessions#new

Showing /Users/chanel.n/svn-    work/gwb/trunk/PMOCCU/ProcessEnforcer/app/views/devise/sessions/new.html.erb where line #5 raised:

undefined method `email' for #
Extracted source (around line #5):

2: 
3:  resource_name, :url => session_path(resource_name)) do |f| %>
4:   
5: 6: 7:
8: Rails.root: /Users/chanel.n/svn-work/gwb/trunk/PMOCCU/ProcessEnforcer Application Trace | Framework Trace | Full Trace app/views/devise/sessions/new.html.erb:5:in `block in _app_views_devise_sessions_new_html_erb___4179931318693150703_70215900182100' app/views/devise/sessions/new.html.erb:3:in `_app_views_devise_sessions_new_html_erb___4179931318693150703_70215900182100'

Here is my User Model which includes email:

class User < Role
has_and_belongs_to_many :roles

attr_accessible :name, :roles

# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
     :lockable, :timeoutable, :trackable, :validatable, :token_authenticatable

# Setup accessible (or protected) attributes for your model
attr_protected :email, :password, :password_confirmation, :department, :encrypted_password 
# attr_accessible :title, :body, :remember_me

 validates_presence_of :email

end

For whatever reason, it it not recognizing email.

Has anyone else run into this issue?

  1. Your email field is not accessible in the User model,You should make it accessible by using:

    attr_accessible :name, :roles, :email
    
  2. Devise by default uses email as the login so it requires you to have the :email and :encrypted_password fields.

    You don’t have either in your User model. So, you need to add those fields.

Originally posted 2013-11-09 21:08:03.