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 Build a Simple Ruby on Rails Application Frontend Development ERB Basics

I need help with this challenge.

I'm a newbie and I'm stuck on this challenge. I'm not understanding exactly what it's asking. Can someone please better explain or provide more clarity.

Loop through our statuses array in an ERB template. Assume we have statuses set up as an array and want to print out the name.

<% @statuses.each do |status| %>
  Name: <br />
<% end %>

6 Answers

When dealing with ERB templates, you have two types of tags: <% %> which do something and <%= %> which output something. In this case, you already have the code that does something. It loops through an array of statuses. Those statuses have properties, and one of the properties is a name. To access that property, you'd write status.name.

So, your task is to output the names of the statuses, after Name:.

Does this clarify the situation a bit?

A lot more clarity in your answer Dino Paškvan

So as you can see the each loop is looping through the statuses and assigning them to a variable called status (the bit between the | | ). So to grab the name is as simple as below.

<% @statuses.each do |status| %>
  Name: <br /> <%= status.name %>
<% end %>

You see we ref the status variable and call the name on it

Oh! I see, I got it now and Thank you so very much!!!

I would like you to check something to pre-empt a problem I see alot on the forum. Could you run the follwoing command from the command line and post the response here.

rails -v

The reason I ask is if you don't see version 3.2 then you are going to run into problems later on in the course. As things have changed since then, most people will see Rails 4.0.0

Yes! Dino and Hi Dino and Thanks!!!

I see 4.0.0

Then I would suggest you restart the project and ensure you are using rails 3.2. It will cause errors shortly on the course of the use of attr_accessible was taken out of rails 4.

Okay, thanks!