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
Patrick Barber
Courses Plus Student 1,709 PointsNoMethodError in Statuses#index
I tried looking for another post to fix this error but couldn't find the right answer... I'm sure it's easy, but I'm such a newb! Here's the code:
Showing /Users/Home/Source/projects/treebook/app/views/statuses/index.html.erb where line #9 raised:
undefined method `full_name' for nil:NilClass
<% @statuses.each do |status| %>
<div class="status">
<strong><%= status.user.full_name %></strong>
<p><%= status.content %></p>
<div class="meta">
<%= link_to time_ago_in_words(status.created_at) + " ago", status %>
Rails.root: /Users/Home/Source/projects/treebook
Application Trace | Framework Trace | Full Trace
app/views/statuses/index.html.erb:9:in block in _app_views_statuses_index_html_erb__2859690692118279184_70260199904980'
app/views/statuses/index.html.erb:7:inapp_views_statuses_index_html_erb_2859690692118279184_70260199904980'
Now I've done some "tinkering" (not too much!) to try to fix this but to no avail... Any help is greatly appreciated!
Thanks.
3 Answers
Robert Borsey
Courses Plus Student 9,636 PointsIf this is the case (1) stop the server
(2) rake db:drop
(3) rake db::create
(4) rake db:migrate
This worked for me it sounds like the same problem I had ( NO GUARANTES) Let me know if it works.
Patrick Barber
Courses Plus Student 1,709 PointsMY MAN! That DID fix it, as well as finishing the "Navigation Links" video. I had tried a few of those commands, but I did not see the "db:create" command anywhere else. Thank you good sir!
Robert Borsey
Courses Plus Student 9,636 Pointscool glad to help
Paul Razgaitis
11,362 PointsSame problem for me, this worked for me too! You da man, Robert!!
Jordan Saxe
4,713 PointsAre you running Ruby 2 and Rails 4? Im having the same issue and cant fix it.
Patrick Barber
Courses Plus Student 1,709 PointsYes, I am. Also just upgraded to maverick. Hope that doesn't put a wrench in the gears...
Jordan Saxe
4,713 PointsHad a Rails dev help me with this. Looks like I had a old user with no User_id that had a status associated with it.
Fixed anyways.
Robert Borsey
Courses Plus Student 9,636 PointsRobert Borsey
Courses Plus Student 9,636 PointsAre you able to see any of you pages or are you getting errors on all pages