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

Casey Clayton
Casey Clayton
16,708 Points

Creating Relationships Problem

Ok I am at the stage where you edit the show page and add in the full_name variable so that it shows the users full name. Now this works fine on the show page, but if I copy and paste that exact code to the index where it shows I get an error. I find it odd that the exact same code works on one page but errors out on the other.

Casey Clayton
Casey Clayton
16,708 Points

undefined method `user' for nil:NilClass Extracted source (around line #9):

Error Message:

6: 
7: <% @statuses.each do |status| %>
8: <div class=" status">
9: <b><%= @status.user.full_name %></b>
10: <p><%= status.content %></p>
11: <div class="meta">
12:   <%= link_to time_ago_in_words(status.created_at) + " ago", status %>
Casey Clayton
Casey Clayton
16,708 Points

Ok I figured it out, rather than having @status like in the video its just status.user.full_name without the @ symbol

1 Answer