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!
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

Brian Goldstein
19,419 PointsGenerating the User Model: "undefined method 'each'
After installing devise, I'm able to go to localhost:3000/users/sign_up and create a new user, no problem. Yay! but, my status/index page now won't load. This is the error message I'm getting:
Showing C:/Sites/Treebook/app/views/statuses/index.html.erb where line #7 raised:
undefined method `each' for nil:NilClass
Extracted source (around line #7):
4:
5: <%= link_to "Post a New Status", new_status_path, class:"btn btn-statuses" %>
6:
7: <% @success.each do |status| %>
8: <div class="status hover">
9: <strong><%= status.name %></strong>
10: <p><%= status.content %></p>
any ideas what to do?
2 Answers

Alan Johnson
7,625 PointsIt looks like @success
is nil. Should it be a different variable, like @statuses
?

Brian Goldstein
19,419 PointsAlan -
that was it. thanks!
to recap for posterity:
You must match the variable in your views/statuses/index.html.erb to the status controller file in order to avoid getting the Nil Class error.

Alan Johnson
7,625 PointsAwesome! Can you mark my answer as best answer so that it's helpful to other folks who bump into this in the future?