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

NoMethodError in Statuses#index

I'm currently on http://teamtreehouse.com/library/programming/build-a-simple-ruby-on-rails-application/customizing-forms/creating-relationships and came across the following NoMethodError:

http://cl.ly/image/3s3f0p1o0O2U

I'm a Ruby-Newb so can someone please help me? I'm great in following along with the tuts until something goes wrong...like now..argh. :(

1 Answer

What does your StatusesController look like for the index method? I think you ran into a gotcha. That is, if there are no statuses to display, @statuses is nil.

Try doing this before listing your statuses (before @statuses.each and after the corrosponding end)

<% if @statuses %> <% @statuses.each do |status| %> random stuff <% end %> <% end %>

That way you can check to see if you have statuses in the first place ;)

Let me know.