0
我需要创建一种演绎查询,其中相同的记录被多次排序,每次的订单都独立于先前的订单执行。如何两次订购相同的记录集,第二个订单独立于第一个订单执行?
如:
tallest_trees = Trees.order(:height => :desc).limit(10) # Gets 10 of the tallest trees out of all available trees
tallest_trees.order(:width => :desc) # From the 10 of the tallest trees, gets the widest trees **without** any regard to their height
我试图做一个类似的方式如上,但结果一直是它试图订购,在这种情况下,树木,都同时按高度和宽度,这与我的需求相反。
关于直接使用ActiveRecord或SQL没有任何区别。我相信答案是我必须“稳定”以前的查询,以便第二个查询不会继续,而是重新命令它。
'reorder'这就是它!谢谢! – Kasperi 2014-10-19 15:13:11