-1

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.

user1943992
  • 222
  • 3
  • 11
  • This comes up over and over and over again and it is always the same thing, hence the duplicate. To be fair, it can be difficult to find all the duplicates. – mu is too short Aug 05 '15 at 21:46
  • I didn't know that this was the issue I was having so I was not sure what to search for. Should I delete this now that I know? – user1943992 Aug 25 '15 at 14:28

1 Answers1

5

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).

spickermann
  • 81,597
  • 8
  • 83
  • 112