views:

18

answers:

1

In a given html.erb file, I have

<%= render "steps_list", :post => @post%>

In _steps_list.html.erb, I have

<%= @post.step_names.each do |step| %>
    Step: <%= "#{step}" %>
<% end %>

This works well with one exception. Each step is printed out as I want, but the entire array is also printed out at the end.

Step: Rinse Step: Lather Step: Repeat RinseLatherRepeat

I suspect the entire array is printed out at the end because the closure returns the array when it's finished executing. How do I suppress the printing of the array or the return value of the closure?

+2  A: 

Use this instead.

<% @post.step_names.each do |step| %>
    Step: <%= "#{step}" %>
<% end %>

<%= ### %> means "print the output of this".

jdl
D'oh. Newbie here, needless to say. Thanks. :)
Sanjay
You're welcome. Enjoy.
jdl