In a partial I have:
<%= shift.ones.times do %>
<p>one</p>
<% end %>
The final HTML (from the page source) is:
<p>one</p>
1
Why is this? How can I stop it?
Thanks in advance.
In a partial I have:
<%= shift.ones.times do %>
<p>one</p>
<% end %>
The final HTML (from the page source) is:
<p>one</p>
1
Why is this? How can I stop it?
Thanks in advance.
Just change <%=
to just <%
:
<% shift.ones.times do %>
<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).