jeudi 29 octobre 2015

How to write multiple queries in 'Order' clause with limits defined in rails

I have a model 'Product'. My requirement is to get all products in this fashion , top 20 products should be in order of created_at and remaining all should be in order of 'updated_at'. Right now my query is Product.order('created_at DESC,updated_at DESC'), but this gives me all products in order of 'created_at'. I want to put a limit clause inside 'order' clause. Any suggestions on how to achieve this?

Aucun commentaire:

Enregistrer un commentaire