Skip to content Skip to sidebar Skip to footer

Embedded Ruby Html Loops Spit Out Number Of Loop

In a partial I have: <%= shift.ones.times do %>

one

<% end %> The final HTML (from the page source) is:

one

1 Why is this? How

Solution 1:

Just change <%= to just <%:

<% shift.ones.timesdo %>
  <p>one</p>
<% end %>

This happens because <%= evaluates the expression and prints the returned value, whereas <% just evaluates the expression. And the times method returns the number of times the block was processed (1 time in your example).

Post a Comment for "Embedded Ruby Html Loops Spit Out Number Of Loop"