User.find(:all, :order => "RANDOM()", :limit => 10)
是我在 Rails 3 中的做法。
User.all(:order => "RANDOM()", :limit => 10)
我认为 Rails 4 会这样做,但这仍然给了我一个弃用警告:
DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. `Post.where(published: true).load`). If you want to get an array of records from a relation, you can call #to_a (e.g. `Post.where(published: true).to_a`).