I am trying to make a responsive image grid (here is an example from w3schools: Responsive Image Grid). From the example, they have the following html:
<div class="row">
<div class="column">
<img src="/w3images/wedding.jpg" style="width:100%">
<img src="/w3images/rocks.jpg" style="width:100%">
<img src="/w3images/falls2.jpg" style="width:100%">
<img src="/w3images/paris.jpg" style="width:100%">
...
</div>
<div class="column">
<img src="/w3images/underwater.jpg" style="width:100%">
<img src="/w3images/ocean.jpg" style="width:100%">
<img src="/w3images/wedding.jpg" style="width:100%">
<img src="/w3images/mountainskies.jpg" style="width:100%">
...
</div>
<div class="column">
<img src="/w3images/wedding.jpg" style="width:100%">
<img src="/w3images/rocks.jpg" style="width:100%">
<img src="/w3images/falls2.jpg" style="width:100%">
<img src="/w3images/paris.jpg" style="width:100%">
...
</div>
<div class="column">
<img src="/w3images/underwater.jpg" style="width:100%">
<img src="/w3images/ocean.jpg" style="width:100%">
<img src="/w3images/wedding.jpg" style="width:100%">
<img src="/w3images/mountainskies.jpg" style="width:100%">
...
</div>
</div>
However, they are using static content. I want to make the content dynamic. I've done some research and found the following solution: Return every nth row from database using ActiveRecord in rails. Not sure if this is the right way, but my goal is to put every n element in each column without specifying the limit.
Currently, I have the following code in my controller:
def index
@photos = Photos.is_active.all
end
Index view:
= render partial: "photos", collection: @photos
Is there any right way to implement the solution from w3school and make a dynamic content with Ruby on Rails loop?