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

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