Mistři v programování na #hovnokod

Ruby #308

#Before refactoring:

<% @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 -%>

#After:

<% @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 %>

HovnoKod,