相关疑难解决方法(0)

找到一些随机记录的'Rails 4 Way'是什么?

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`).
Run Code Online (Sandbox Code Playgroud)

random ruby-on-rails-4

44
推荐指数
6
解决办法
3万
查看次数

标签 统计

random ×1

ruby-on-rails-4 ×1