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

Having some trouble completing this code challenge.

Not sure of what this question is describing.

1 Answer

Gavin Ralston
Gavin Ralston
28,770 Points

In the video prior to this challenge it'll go over the template syntax and how to drop into and out of the HTML output by surrounding ruby code with tags.

So for instance:

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

Those two opening and closing commands there, they're never displayed anywhere in the HTML at all, right? They're just there so you can "drop in" to ruby and execute a loop, which DOES output the following for each status in statuses:

Name: <br/>

So the question here is... how do you drop back into ruby for a moment after the "Name: " part and have the information actually display to the page?

You'll want to use the opening tag with an equal sign in front of it, to indicate the output should be put into your page, not just run in the background

<%= "Stuff to be on HTML page" %>

So...

<% @students.each do |student| %>
  Grade: <%= student.gpa %> <br />
<% end %>

Hope that helps a bit.