Rails activerecord get Model. all using an order by
By default, when you do Model.all in rails, it returns data based on whatever order was returns by the database. But sometimes thats not what you want. For example, if I had a model called 'Product' and wanted to retrieve all the products by order_date, here's what you need to write in your controller.
Product.order('order_date DESC');