I have this scope. I would like to have it set up to return batches of 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
Straight from the docs; untested, but I don't see why this wouldn't work.
YourUnidentifiedModel.get_some_stuff.find_in_batches(batch_size: 25) do |batch|
# Work with your batch
end