有没有办法让这个范围成批return结果
Is there a way to get this scope to return results in batches
我有这个范围。我想将其设置为 return 批 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
我有这个范围。我想将其设置为 return 批 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