class ActiveRecord::Batches::BatchEnumerator
def destroy_all
Person.where("age < 10").in_batches.destroy_all
Destroys records in batches. Returns the total number of rows affected.
def destroy_all sum do |relation| relation.destroy_all.count(&:destroyed?) end end