instance method destroy_all

Ruby on Rails 7.2.3

Since v6.1.7.10

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

destroy_all()

Destroys records in batches. Returns the total number of rows affected.

Person.where("age < 10").in_batches.destroy_all

See Relation#destroy_all for details of how each batch is destroyed.

Source
# File activerecord/lib/active_record/relation/batches/batch_enumerator.rb, line 96
      def destroy_all
        sum do |relation|
          relation.destroy_all.count(&:destroyed?)
        end
      end

Defined in activerecord/lib/active_record/relation/batches/batch_enumerator.rb line 96 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Batches::BatchEnumerator

Type at least 2 characters to search.

↑↓ navigate · open · esc close