views:

16

answers:

0

I'm trying to generate some divs using div_for inside of an each block. The result is that every div has the same id and class. The documentation says that each div should have a unique id (which is what I want).

Here's the code I'm using:

<% @pallet.boxes.each do |box| %>
 <%= div_for(box) do %>
  <h2><%= box.name %></h2>
  <p>some stuff in here</p>
 <% end %>
<% end %>

Here is a snippet of the page source:

<div class="box" id="new_box"> 
    <h2>box1</h2>
    <p>some stuff in here</p>           
</div>      

<div class="box" id="new_box"> 
    <h2>box2</h2>
    <p>some stuff in here</p>           
</div>

<div class="box" id="new_box"> 
    <h2>box3</h2>
    <p>some stuff in here</p>           
</div>