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!
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

Andrew Martin
17,513 PointsGenerating the User Model : undefined method `first_name'
So (I think) I've been following the videos word for word, yet I seem to be running into an error just after adding in the modifications to the sign up page in new.html.erb where you need to add text fields for First Name, Last Name and Profile Name.
After migrating, I seem to be getting this error :
" NoMethodError in Devise/registrations#new
Showing C:/Users/Andrew/Projects/treebook/app/views/devise/registrations/new.html.erb where line #6 raised:
undefined method `first_name' for #<User:0x3cbc8b0> "
Which of course is now driving me crazy because as I say, I think I've followed everything correctly. I'm aware that there is actually supposed to be a error showing by the end of this section, but... I'm not there yet, this is a different error showing just before I get to the 'planned' one. I know its impractical to show my entire code for every single bit so I can identify where I've obviously made a mistake, but, could anyone please offer advice on where I should be looking in terms of common mistakes?
Thanks.
EDIT
Thanks anyways but I have since solved my problem, I dont know why but for some reason my migrations were not working, so, to fix it, I used db:rollback and the db:migrate again and this fixed it.
4 Answers

Lior Kesos
1,445 PointsI had this problem also and this is very simple 1) rake db:rollback 2) rake db:migrate

Jason Seifer
Treehouse Guest TeacherHey Andrew, glad you figured it out! Let us know if you have any more problems.

Drew Templeton
6,509 PointsJason Seifer - If I rename a migration and run rake db:migrate again will this fix this sort of issue? I've run into problems before where I missed something in my migration after I ran db:migrate, but when I make the changes and run it again, it doesn't change the existing migration.
Or is running rollback always the best case? Does rollback only rollback the most recent migration?

Jason Seifer
Treehouse Guest TeacherYou always have to rollback. Renaming a migration will mess things up potentially.

Josh Flowers
7,010 PointsI'm trying to do a db:rollback, but it's telling me that the "command not found"
Robert Cekay
12,460 PointsRobert Cekay
12,460 PointsYou sir just saved my life, would you mind shedding some light on why this worked. Thanks again!
Robert Cekay
12,460 PointsRobert Cekay
12,460 PointsYou sir just saved my life, would you mind shedding some light on why this worked. Thanks again!