- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
Было (плохо):
<% @collection.each_with_index do |item, counter| -%>
<%= "<div class='group'>" if ((counter)/items_in_block).to_i*items_in_block == (counter) %>
<%= render :partial => 'item', :locals => { :item => item} %>
<%= "</div>" if (counter > 0 and (((counter+1)/items_in_block).to_i*items_in_block == (counter+1)) or ((counter+1) == @collection.size)) %>
<% end -%>
Стало (чуть лучше ;):
<% @collection.in_groups_of(items_in_block).each do |items| %>
<div class="group">
<% items.each do |item| %>
<%= render :partial => 'item', :locals => { :item => item} %>
<% end %>
</div>
<% end %>
guest 07.04.2011 11:58 # 0
guest 08.04.2011 10:35 # −2
malleus 22.04.2011 15:46 # +2
<%= render :partial => 'item', :locals => { :item => item} %>
<% end %>
можно заменить на
<%= render @items %>
Ваш К.O.