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

Creating 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

Figured it out.

What was it?

I 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.

how did you find the user_id?

i went into the rails console and ran Users.all or User.all. To get a list of the users.

I'll try this out tonight.

Thanks. I'll try this out tonight.