开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜