Ruby on rails foreach with bootstrap3 row class

后端 未结 1 903
梦如初夏
梦如初夏 2021-02-08 22:30

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

相关标签:
1条回答
  • 2021-02-08 23:09

    use Enumerable#each_slice

    <% @work.each_slice(3) do |works| %>
      <div class="row">
        <% works.each do |work| %>
          <div class="col-md-4">*work.name*</div>
        <% end %>
      </div>
    <% end %>
    
    0 讨论(0)
提交回复
热议问题