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

Ruby

Treebook App - Having issues with first_name

If you have been struggling like me, you immediately recognise the problem. When I am trying to show the first name in this exercise (Programming Build a Simple Ruby on Rails Application Customizing Forms Creating Relationships), it won't show the actual name of the person, but gives an error, which is: undefined method `first_name' for nil:NilClass

what could this be?

3 Answers

Hi Derrick,

Seems like my ID got 2 rather than 1. So in the video it says you should use 1, but in my case it was 2 and it passed without a problem!

I am now doing validations, so got moving on!

Thanks

Niels

Derrick Mull
Derrick Mull
18,518 Points

Sounds like you still have statuses with no(nil) User information. Make sure the old statuses with no User information are deleted.

Rails is complaining that there is no "first_name" information available and is telling you there is nil to retrieve from status.user.first_name.

Yes, I found using id 2 works. Perhaps the -rm command didn't reset the user_id #, so when we added our user profile again, the user_id was set to 2.