I would like to foreach loop through data and display this data usings bootstraps grid system having 3 columns per row, however i will need multiple rows for the amount of data as below:
<div class="row">
<div class="col-md-4">*DATA HERE*</div>
<div class="col-md-4">*DATA HERE*</div>
<div class="col-md-4">*DATA HERE*</div>
</div>
<div class="row">
<div class="col-md-4">*DATA HERE*</div>
<div class="col-md-4">*DATA HERE*</div>
<div class="col-md-4">*DATA HERE*</div>
</div>
<div class="row">
<div class="col-md-4">*DATA HERE*</div>
<div class="col-md-4">*DATA HERE*</div>
<div class="col-md-4">*DATA HERE*</div>
</div>
Can someone advise how to achieve this using a foreach in rails, obviously the below would only render 1 .row class and place all col-md-4 items returned into it. I would like it to create another .row class after it reaches 3 items per row and start again. I hope that makes sense! What i have so far:
<div class="row">
<% @work.each do |w| %>
<div class="col-md-6">
<%= w.image_url %>
</div>
<% end %>
</div>
use Enumerable#each_slice