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# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -