Say I have 16 objects in my collection, I want to create 4 rows of 4 each.
How do I do that using partials?
One way is to just use one partial on the main page, and have that partial render each row. Then inside that partial, have it 4 objects - but how do I actually do that such that it doesn't repeat objects and all this good stuff?
So the structure I am thinking is a partial (that produces 4 rows) and in each partial is another partial that produces 4 objects side by side.
But not quite sure how to pull that off.
Suggestions?
<% @objects.in_groups_of(4, false) do |objects| %>
<div class="row">
<% objects.each do |object| %>
<%= render object %>
<% end %>
</div>
<% end %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.