{"id":621,"date":"2022-08-30T15:04:24","date_gmt":"2022-08-30T15:04:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/devise-undefined-method-email-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:04:24","modified_gmt":"2022-08-30T15:04:24","slug":"devise-undefined-method-email-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/devise-undefined-method-email-collection-of-common-programming-errors\/","title":{"rendered":"Devise undefined method `email&#39;-Collection of common programming errors"},"content":{"rendered":"<p>Whenever I hit the sign in button I get the following error:<\/p>\n<pre><code>NoMethodError in Devise\/sessions#new\n\nShowing \/Users\/chanel.n\/svn-    work\/gwb\/trunk\/PMOCCU\/ProcessEnforcer\/app\/views\/devise\/sessions\/new.html.erb where line #5 raised:\n\nundefined method `email' for #\nExtracted source (around line #5):\n\n2: \n3:  resource_name, :url =&gt; session_path(resource_name)) do |f| %&gt;\n4:   <br \/>\n5:   \n6: \n7:   <br \/>\n8:   \nRails.root: \/Users\/chanel.n\/svn-work\/gwb\/trunk\/PMOCCU\/ProcessEnforcer\n\nApplication Trace | Framework Trace | Full Trace\napp\/views\/devise\/sessions\/new.html.erb:5:in `block in    _app_views_devise_sessions_new_html_erb___4179931318693150703_70215900182100'\napp\/views\/devise\/sessions\/new.html.erb:3:in `_app_views_devise_sessions_new_html_erb___4179931318693150703_70215900182100'\n<\/code><\/pre>\n<p>Here is my User Model which includes email:<\/p>\n<pre><code>class User &lt; Role\nhas_and_belongs_to_many :roles\n\nattr_accessible :name, :roles\n\n# Include default devise modules. Others available are:\n# :token_authenticatable, :confirmable,\n# :lockable, :timeoutable and :omniauthable\ndevise :database_authenticatable, :registerable,\n     :lockable, :timeoutable, :trackable, :validatable, :token_authenticatable\n\n# Setup accessible (or protected) attributes for your model\nattr_protected :email, :password, :password_confirmation, :department, :encrypted_password \n# attr_accessible :title, :body, :remember_me\n\n validates_presence_of :email\n\nend\n<\/code><\/pre>\n<p>For whatever reason, it it not recognizing email.<\/p>\n<p>Has anyone else run into this issue?<\/p>\n<ol>\n<li>\n<p>Your email field is not accessible in the User model,You should make it accessible by using:<\/p>\n<pre><code>attr_accessible :name, :roles, :email\n<\/code><\/pre>\n<\/li>\n<li>\n<p>Devise by default uses email as the login so it requires you to have the :email and :encrypted_password fields.<\/p>\n<p>You don&#8217;t have either in your User model. So, you need to add those fields.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:08:03. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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&#8217; for # Extracted source (around line #5): 2: 3: resource_name, :url =&gt; session_path(resource_name)) do |f| %&gt; 4: 5: 6: 7: 8: Rails.root: \/Users\/chanel.n\/svn-work\/gwb\/trunk\/PMOCCU\/ProcessEnforcer Application Trace | Framework Trace | Full [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-621","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/621","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=621"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/621\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}