0
我有这个范围。我想将它设置为返回的25有没有办法让这个范围批量返回结果
scope :get_some_stuff, lambda {
select(QUERY_SELECT).
joins(QUERY_JOINS).
group(QUERY_GROUP_BY)
}
我有这个范围。我想将它设置为返回的25有没有办法让这个范围批量返回结果
scope :get_some_stuff, lambda {
select(QUERY_SELECT).
joins(QUERY_JOINS).
group(QUERY_GROUP_BY)
}
http://guides.rubyonrails.org/active_record_querying.html#retrieving-multiple-objects-in-batches
直从文档批次;未经测试,但我不明白为什么这不起作用。
YourUnidentifiedModel.get_some_stuff.find_in_batches(batch_size: 25) do |batch|
# Work with your batch
end
那么是什么引起的呢?我的答案是否有效? – JakeTheSnake