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

Chase Lee
29,275 PointsBuild a Simple Ruby on Rails Application > Frontend Development > ERB Loops
Hi everyone,
I was doing the ERB loops code challenge by Jim Hoskins and ran into a problem. In task one it asks me to: "Wrap the status div with an erb each loop. Use the @statuses variable's .each method, and use a ruby block that uses a local parameter called status."
Here is what passed:
<div class="page-header">
<h1>All Statuses</h1>
</div>
<% @statuses.each do |status| %>
<div class="status">
<% end %>
<h2></h2>
<p> </p>
</div>
Nothing else worked for me. Then in order to pass task two which asked:
"Use an erb output tag to place the name of each status, using the status.name method."
I needed to put the loop all the way around the div
like this:
<div class="page-header">
<h1>All Statuses</h1>
</div>
<% @statuses.each do |status| %>
<div class="status">
<h2>Name: <%= status.name %></h2>
<p> </p>
</div>
<% end %>
Is it just me, or is something wrong?

Greg Leibowitz
28,536 PointsI mean this:
<div class="page-header">
<h1>All Statuses</h1> </div>
<% @statuses.each do |status| %>
<div class="status"> <h2> </h2> <p> </p> </div> <% end %>
4 Answers

Marcus Tisäter
4,886 PointsYou haven't used @status. It's an instance variable.

Chase Lee
29,275 PointsWhere do I need to use it?

P MCN
182 PointsI dont have a clue how to fix this either... baffled

Mathias Menzl
7,366 Pointsthis worked
<div class="page-header">
<h1>All Statuses</h1>
</div>
<% @statuses.each do |status| %>
<div class="status">
<h2> </h2>
<p> </p>
</div>
<% end %>
Greg Leibowitz
28,536 PointsGreg Leibowitz
28,536 PointsIt looks like you got a little ahead of yourself and changed the h2: <h2>Name: <%= status.name %></h2>
This worked for me for "Wrap the status div with an erb each loop. Use the @statuses variable's .each method, and use a ruby block that uses a local parameter called status. Question 1 of 3":
<div class="page-header"> <h1>All Statuses</h1> </div>
<% @statuses.each do |status| %>
<div class="status"> <h2> </h2> <p> </p> </div> <% end %>