I have a each block something like:
<% for f in @following %>
<div class="span6">
<%= f.name %>
</div>
<% end %>
html result:
<div class="span6"> John</div>
<div class="span6"> kevin</div>
<div class="span6"> Peter</div>
<div class="span6"> Andrew</div>
.
.
.
I want add a <div class="row"></div>
each 2 results something like:
<div class="row">
<div class="span6"> John</div>
<div class="span6"> kevin</div>
</div>
<div class="row">
<div class="span6"> Peter</div>
<div class="span6"> Andrew</div>
</div>
I want show 2 results per/row. How can I do it?
Checkout each_slice
<% @following.each_slice(2) do |followers| %>
<div class="row">
<% followers.each do |f| %>
<div class="span6">
<%= f.name %>
</div>
<% end %>
</div>
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With