Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.