Dynamically name class on rails view? -


i have each loop , want use index var name dynamically have tried didn't work.

<% (0..4).each |i| %> <div id="item-<%= #{i} %>" class="hold-button"> 

try this:

<% (0..4).each |i| %>   <div id="item-<%= "#{i}" %>" class="hold-button"> <% end %> 

or

<% (0..4).each |i| %>   <div id="item-<%= %>" class="hold-button"> <% end %> 

remember: #{} used embedded variable strings. that's why code doesn't work.


Comments

Popular posts from this blog

c# - Attribute value in root node of xml Linq to XML -

ios swift - uiimage array to video disorted and flipped -

scala, transform a callback pattern to a functional style internal iterator -