<% @images.each_with_index do |page, index| %>
<% end %>
The two answers are good. And I also suggest you a similar method:
<% @images.each.with_index do |page, index| %>
<% end %>
You might not see the difference between this and the accepted answer. Let me direct your eyes to these method calls: .each.with_index
see how it's .each
and then .with_index
.
Try each_with_index.
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