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


Mike Graham
Mike Graham
3,325 Points

undefined method 'user' in Treebook "Creating Relationships" section

I've gotten stuck on the Treebook tutorial. When working through the "Creating Relationships" video, I receive the following error on /statuses/show.html.erb

undefined method `user' for #<Status:0x007ff1fbb8ccd0>

Extracted source (around line #5):

2: 3: <p> 4: <b>Name:</b> 5: <%= @status.user.first_name %> 6: </p> 7: 8: <p>


3 Answers

I was having this problem too. I definitely suggest following this advice from another user:

"I was stumped by the same error for a while. I kept clearing all statuses and users from the database using the rails console, then generating a new user and new statuses. I still would receive this same error message.

The issue was I was providing an incorrect user_id.

When you "sign up" for the site, look in the command prompt window and find the message associated with adding a new user to the database (you may have to scroll up). Near the end of that message, it will tell you the user_id associated with that user. Try plugging that in when writing a status. That fixed the problem for me!"

Mike Graham
Mike Graham
3,325 Points

Thanks Jason,

I backed up and went through the project again and it worked perfectly. Not sure what I missed the first time...

Great course. Thanks.