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

eric Lee
2,546 PointsBuild a Simple Ruby on Rails Application-Creating Relationships
Hi, I need help about Creating Relationships. When i follow the introduction on this part, i add has_many :statuses and belongs_to :user to each model, and finished the view part. However, when i run server it comes out "undefined method `first_name' for nil:NilClass" in show.html.erb file also the same problem in index file. I already used the Status.delete_all in console. it still don't work. Please advise
OK, I fixed it.
2 Answers

Adam Flanagan
8,022 PointsHow did you fix this??!!

Aaron Kaye
1,740 PointsYeah I am having that same problem, for me, when I go into my console and run User.all I see that my first_name, last_name, and profile_name have not been set (they are just nil). So I tried to delete the user and re-register but again I end up with nil for those three fields, maybe that has something to do with it and is a similar problem to what you're having
John Corser
5,660 PointsJohn Corser
5,660 Pointsdid you figure out how he did it?
Aaron Kaye
1,740 PointsAaron Kaye
1,740 PointsHey, not sure if this will help but I was getting a similar problem. Heres a link to my posting where I posted how I fixed it. I was getting an error that said this: NoMethodError in Statues#show. "undefined method "full_name" for nil:NilClass. Hope that helps some!
https://teamtreehouse.com/forum/problem-with-devise-in-simple-ruby-on-rails-app
John Corser
5,660 PointsJohn Corser
5,660 PointsThis is exactly what I needed! Thanks for replying so quickly!
John Corser
5,660 PointsJohn Corser
5,660 PointsHave you also had to use different bootstrap classes?
There are also a few steps that I didn't have to do, like deleting index.erb and setting accessible attributes to models.
Aaron Kaye
1,740 PointsAaron Kaye
1,740 PointsYoure welcome! Glad it helped. Yeah I didn't have to do the attr_accessible part, not exactly sure what it does and any consequences of not doing it. Yeah had to use a few different class names in bootstrap as well. Just tried to find the equivalent on the bootstrap site lol. Good luck!