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
Ryan Flournoy
3,839 PointsNew User sign up issues on Ruby Rails
Im having trouble with user registrations with ruby on rails, Ive had issues with following along because I got signed in and dont know how to sign out (of the treebook app thing),
I also "destroyed" a "first" user. (not sure if this is the issue (error msg:
undefined method `first_name' for #<User:0x000001038fe770>)
now my new text fields (on user//users/sign_up.)
wont come up, and i get this error:
NoMethodError in Devise/registrations#new
Showing /Users/macuser/treebook/app/views/devise/registrations/new.html.erb where line #7 raised:
undefined method `first_name' for #<User:0x000001038fe770>
Extracted source (around line #7):
4: <%= devise_error_messages! %>
5:
6: <div><%= f.label :first_name %><br />
7: <%= f.text_field :first_name %></div>
8:
9: <div><%= f.label :last_name %><br />
10: <%= f.text_field :last_name %></div>
Rails.root: /Users/macuser/treebook
Application Trace | Framework Trace | Full Trace
app/views/devise/registrations/new.html.erb:7:in `block in _app_views_devise_registrations_new_html_erb___1109275127285844006_2154711880'
app/views/devise/registrations/new.html.erb:3:in `_app_views_devise_registrations_new_html_erb___1109275127285844006_2154711880
Please help.
Thanks
3 Answers
Jason Seifer
Treehouse Guest TeacherHey Ryan,
Try zipping up your code and emailing it to help@teamtreehouse.com so we can troubleshoot this.
Ryan Flournoy
3,839 PointsThanks Jason,
But I already figured it out. But still have a question.
What I did was, miss-spell one of my new registration form text strings things in the db/migrate/ devise create user (I spelled it :comany_name instead of company_name) , saved it or did the next step in creating the data base then when I started adding the fields they wouldn't match up and I would get a no method error.
Ive gone though and got it to work, but now that field is titled "comany" instead of "company", I guess my question now is "how do I change this, to company?" or "how do I re-title a column in my users table, without screwing everything up?"
Jason Seifer
Treehouse Guest TeacherHey Ryan,
You can add a migration and rename the column from there:
rails generate migration change_company_name
Then open the migration and add the folowing:
rename_column :users, :comany_name, :company_name
Hope that helps!