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

Chase Lee
Chase Lee
29,275 Points

Build 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
Greg Leibowitz
28,536 Points

It 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 %>

Greg Leibowitz
Greg Leibowitz
28,536 Points

I 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
Marcus Tisäter
4,886 Points

You haven't used @status. It's an instance variable.

Chase Lee
Chase Lee
29,275 Points

Where do I need to use it?

I dont have a clue how to fix this either... baffled

Mathias Menzl
Mathias Menzl
7,366 Points

this worked

<div class="page-header">
  <h1>All Statuses</h1>
  </div>

<% @statuses.each do |status| %>
<div class="status">
    <h2> </h2>
    <p> </p>
</div>
<% end %>