aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index 4a7d8ed74a..f5e911c739 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -121,13 +121,11 @@ module ActiveRecord
# Deletes the records according to the <tt>:dependent</tt> option.
def delete_records(records, method)
if method == :destroy
- count = records.length
records.each(&:destroy!)
- update_counter(-count) unless inverse_updates_counter_cache?
+ update_counter(-records.length) unless inverse_updates_counter_cache?
else
scope = self.scope.where(reflection.klass.primary_key => records)
- count = delete_count(method, scope)
- update_counter(-count)
+ update_counter(-delete_count(method, scope))
end
end