Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jeffery Davis
272 PointsRunning into trouble with Generating devise views tutorial
here is the error I am getting when I go to my /users/sign_up page. I a feel like the methods for last_name are there but I am not sure whats going on and I cant figure it out.
NoMethodError in Devise/registrations#new
Showing /Users/jeff/Desktop/Open/openapp/app/views/devise/registrations/new.html.erb where line #9 raised:
undefined method `last_name' for #<User:0x0000010604ff40> Extracted source (around line #9):
6: <%= f.text_field :first_name %></div>
7:
8: <div><%= f.label :last_name %><br />
9: <%= f.text_field :last_name %></div>
10:
11: <div><%= f.label :profile_name %><br />
12: <%= f.text_field :profile_name %></div>
Rails.root: /Users/jeff/Desktop/Open/openapp
Application Trace | Framework Trace | Full Trace
app/views/devise/registrations/new.html.erb:9:in block in _app_views_devise_registrations_new_html_erb___3881273885012351502_2200291260'
app/views/devise/registrations/new.html.erb:3:inapp_views_devise_registrations_new_html_erb__3881273885012351502_2200291260'
3 Answers
Jason Seifer
Treehouse Guest TeacherHey Jeffery,
Try double checking your migrations. It can't find the "last_name" field. Can you post the contents of db/schema.rb here?
Nikit Saraf
Courses Plus Student 2,782 PointsExact same problem with me too!!. I'm pasting the link containing the contents of my db/schema.rb:
Jason Seifer
Treehouse Guest TeacherNikit Saraf you don't seem to have the first_name and last_name columns. Did you add those to the devise migration? If not you can by doing the following:
rails generate migration add_names_to_users
Open that file and put the following in:
add_column :users, :first_name, :string
add_column :users, :last_name, :string
Then run:
bundle exec rake db:migrate
And you should be good to go.
Rashad Madison
Full Stack JavaScript Techdegree Graduate 26,370 Pointsoh i didn't put those there wither, why do they HAVE to be there can i call them something else like firstName or just use user_name?