开发者

Ruby on Rails: how do I get the top 5 of something?

开发者 https://www.devze.com 2023-01-13 23:55 出处:网络
I have a c开发者_JAVA技巧olumn, money, and I want the top 5 most expensive activeRecord items. How do I do that?find(:all, order => \"money desc\" :limit => 5)

I have a c开发者_JAVA技巧olumn, money, and I want the top 5 most expensive activeRecord items.

How do I do that?


find(:all, order => "money desc" :limit => 5)


Rails 3 (ARel) syntax:

Item.order('items.money DESC').limit(5)
0

精彩评论

暂无评论...
验证码 换一张
取 消