Hi friends,
Today we are going to discuss about reorder in rails. This method is used to override the scope of order and reorder the rows according to the passed arguments.
Example:
Blog.order('title DESC').reorder('published_at') # generated SQL has 'ORDER BY published_at'
To reverse the existing order, reverse_order is used.
Example:
Blog.order('published_at ASC').reverse_order # generated SQL has 'ORDER BY published_at DESC'
Hope you liked it too, For more like this. Click here
0 Comment(s)