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

Rails full_name error

I tried to register for another account and got this error Showing /Users/Freddy/Treehouse/treebook/app/views/statuses/index.html.erb where line #10 raised:

undefined method `full_name' for nil:NilClass
Extracted source (around line #10):

7: 
8: <% @statuses.each do |status| %>
9: <div class="status">
10:   <strong><%= status.user.full_name %></strong>
11:   <p><%= status.content %></p>
12:   <div class="meta">
13:         <%= link_to time_ago_in_words(status.created_at) + " ago", status %> 

The full name worked on my old account. Why isn't it working now?

1 Answer

I had the same issue. You have existing statuses that do not have a first_name or last_name assigned to them. To fix this issue, quit the rails server (control + C) and type the following lines in.

rails console
Status.delete_all
exit
rails s