aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2013-03-11 20:50:22 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2013-03-11 20:50:22 -0400
commitc3829d31866870e852a64f8a1236f3287d41783b (patch)
tree7425e839246fe575012d889a3a9f6c45cc770e05 /activerecord/lib/active_record
parentcae93be0cac32eaa75746dda00454a26c4654be5 (diff)
downloadrails-c3829d31866870e852a64f8a1236f3287d41783b.tar.gz
rails-c3829d31866870e852a64f8a1236f3287d41783b.tar.bz2
rails-c3829d31866870e852a64f8a1236f3287d41783b.zip
dependent: :destroy should call destroy_all
Commit https://github.com/rails/rails/pull/9668 shows warning when `delete_all` is invoked with `:dependent` option `:destroy`. Unfortunately invoking `Post.destroy_all` invokes `post.comments.delete_all` as part of `has_many` callbacks. This commit ensures that instead `post.comments.destroy_all` is invoked and in the process no warning is generated. See issue #9567 for details .
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index f59565ae77..b7b4d7e3ae 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -23,9 +23,10 @@ module ActiveRecord
if options[:dependent] == :destroy
# No point in executing the counter update since we're going to destroy the parent anyway
load_target.each(&:mark_for_destruction)
+ destroy_all
+ else
+ delete_all
end
-
- delete_all
end
end