Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Snippets taken from:
# https://github.com/rails/rails/blob/fc5dd0b85189811062c85520fd70de8389b55aeb/activerecord/lib/active_record/relation/batches.rb#L201
def in_batches(of: 1000, start: nil, finish: nil, load: false, error_on_ignore: nil)
relation = self
# ...
batch_limit = of
# ...
relation = relation.reorder(batch_order).limit(batch_limit)
relation = apply_limits(relation, start, finish)
# ...
end
def batch_order
arel_attribute(primary_key).asc
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.