I have @comments which lets say has 17 records
What I want is the last 4: 14,15,16,17
I tried:
<% @comments.take(4).each do |comment| %>
But that returns the first 4.. How can I grab the last 4 comments, not the first 4
Thanks
You could also do:
@comments.last(4)...
<% @comments.reverse.take(4).each do |comment| %>
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