aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2013-03-11 13:33:22 -0700
committerXavier Noria <fxn@hashref.com>2013-03-11 13:33:22 -0700
commit67b486142bd3ec42d4b1bffd5705aabd6a0cb4e0 (patch)
treedf89d348f2d100a48beb840ea0c6510cf4ebcbf3 /activerecord
parent816e7d14492e2492f3b1431f657c6d7102ae1aff (diff)
parentd71eaf3e3fb9e9a27a40805b0b724667f3b7a16a (diff)
downloadrails-67b486142bd3ec42d4b1bffd5705aabd6a0cb4e0.tar.gz
rails-67b486142bd3ec42d4b1bffd5705aabd6a0cb4e0.tar.bz2
rails-67b486142bd3ec42d4b1bffd5705aabd6a0cb4e0.zip
Merge pull request #9668 from neerajdotname/9567-delete-all-warning
Show warning message if delete_all is firing callbacks
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 5feb149946..c992f51dbb 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -204,6 +204,15 @@ module ActiveRecord
dependent = options[:dependent]
if records.first == :all
+
+ if dependent && dependent == :destroy
+ message = 'In Rails 4.1 delete_all on associations would not fire callbacks. ' \
+ 'It means if the :dependent option is :destroy then the associated ' \
+ 'records would be deleted without loading and invoking callbacks.'
+
+ ActiveRecord::Base.logger ? ActiveRecord::Base.logger.warn(message) : $stderr.puts(message)
+ end
+
if loaded? || dependent == :destroy
delete_or_destroy(load_target, dependent)
else