On 30 July 2010 03:48, Angel Robert Marquez <angel.marquez@gmail.com> wrote:
> <% @items.each do |item| %> <div class="item<%= item.id %>">
> <%= item.record-name %>
> </div> <% end %>
>> I'm trying to render a list of div's with ids "item1", "item2", "item3",
If you're specifically after "item1" rather than "item<item.id>", then
you can use "each_with_index":
<% @items.each_with_index do |item, index| %>
<div class="item<%= index+1 %>">
<%= item.record-name %>
</div>
<% end %>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment