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 Build a Simple Ruby on Rails Application Customizing Forms Creating Relationships

undefined method `last_name' for nil:NilClass

Hello,

I get this error everytime i try to access the databse fields with this method: <%= @status.user.first_name %>

I' ve repeated all of the previous steps 3 times just to be sure that i'm not missing anything but unfortunately it doesn't work.

The message is: undefined method `last_name' for nil:NilClass

Extracted source: <p> <strong>Name:</strong> <%= @status.user.last_name %>

</p>

Do you have any ideas?

Thank you in advance!

1 Answer

Adam Burkenpas
Adam Burkenpas
23,559 Points

Jason, I am getting the same error. Though, I am running rails 4.1.1 and ruby 2.0.0. I also believe that my version of devise is different. This solution fixed it https://teamtreehouse.com/forum/error-when-doing-simple-ruby-on-rails-application