I have following data in database:
1
2
3
4
5
And I would like to get to output this:
3
4
5
I need it to print in the view:
<%car.colors.limit(3).order('created_at ASC').each do |color|%>
...
I know that exists reverse_order, but exist something like reverse sort?
(I know that is possible to load the data into an array and then go through the array, but this way is not very efficient)
How about just doing
<%car.colors.limit(3).order('created_at DESC').reverse.each do |color|%>
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