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 trialSeyoung Kwak
9,091 PointsNoMethodError in Devise::Registrations#new
I'm working on rails project and have couple of issues with the new version of Bootstrap. When I install Devise and put columns of first, last and profile name on new.html.erb file, I've got error message and wasn't able to figure how to solve. ```
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= devise_error_messages! %>
<div class="field"> <div><%= f.label :first_name %><br /> <%= f.text_field :first_name %></div>
<div><%= f.label :last_name %><br /> <%= f.text_field :last_name %></div>
<div><%= f.label :profile_name %><br /> <%= f.text_field :profile_name %></div> </div>
Error Message:
NoMethodError in Devise::Registrations#new
undefined method `first_name' for #<User:0x007feb75a8a1e8>
<%= f.text_field :first_name %></div>
Seyoung Kwak
9,091 PointsHi Maciej, good point. I moved the files to github. https://github.com/sarahkwak/cookiebook.git
The issue file is: app/views/devise/registrations/new.html.erb
2 Answers
Maciej Czuchnowski
36,441 PointsYour User schema does not have the attributes you mention here, like first, last and profile name. You have to run rake db:migrate
to apply the migrations and get those attributes. Also, I see you're using Rails 4.1.6. Bear in mind that this course will not be easy if you're not using version 3.2.
Maciej Czuchnowski
36,441 PointsIf you did run it and they still don't show up, it means you did the rake db:migrate and then modified the user migration. If you, you'd need to do rake db:reset
to delete the whole database and remake it using all the migrations from scratch.
Seyoung Kwak
9,091 PointsThanks Maciej, I've gone through the workaround link you've posted but found that there are still several issues. I think I will just reset and delete the whole database and remake it. Thanks anyway!!
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsYou have to show us the whole file, it's impossible to tell what's wrong by looking at those 4 lines.