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
James White
6,159 PointsCreating Relationships from RoR course
I've been following along with the course and I'm 99% sure I've done everything that the instructors have.
When we get to the part where we add <%= @status.user.first_name %> I get an error saying "undefined method `first_name' for nil:NilClass"
I'm not quite sure how to track this down.
Help?
Thanks!
7 Answers
James White
6,159 PointsFigured it out.
Robbie Green
15,459 PointsWhat was it?
James White
6,159 PointsI think what the problem was I had added 2 users and somehow they weren't indexing at 1, or maybe I deleted a user somewhere? Anyway, I found the user_id of one of them, and assigned that user_id to the posts.
Carlos (Charlie) Salazar
2,845 Pointshow did you find the user_id?
James White
6,159 Pointsi went into the rails console and ran Users.all or User.all. To get a list of the users.
Carlos (Charlie) Salazar
2,845 PointsI'll try this out tonight.
Carlos (Charlie) Salazar
2,845 PointsThanks. I'll try this out tonight.