aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/autosave_association.rb
diff options
context:
space:
mode:
authorAgis- <corestudiosinc@gmail.com>2014-10-13 17:50:32 +0300
committerAgis- <corestudiosinc@gmail.com>2014-10-13 17:50:32 +0300
commit719d52db42a0eeebf0f1fa2f8ac3173544dd521e (patch)
tree63b18091ff85b230f4708f0ebfad5b6e6f362562 /activerecord/lib/active_record/autosave_association.rb
parent51278579477eb7ee20fe2aba53b4b13203791b22 (diff)
downloadrails-719d52db42a0eeebf0f1fa2f8ac3173544dd521e.tar.gz
rails-719d52db42a0eeebf0f1fa2f8ac3173544dd521e.tar.bz2
rails-719d52db42a0eeebf0f1fa2f8ac3173544dd521e.zip
Autosave callbacks shouldn't be `after_save`
068f092ced8483e557725542dd919ab7c516e567 registered autosave callbacks as `after_save` callbacks. This caused the regression described in #17209. Autosave callbacks should be registered as `after_update` and `after_create` callbacks, just like before. This is a partial revert of 068f092ced8483e557725542dd919ab7c516e567. Fixes #17209.
Diffstat (limited to 'activerecord/lib/active_record/autosave_association.rb')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index c384e8c413..a0d70435fa 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -184,7 +184,9 @@ module ActiveRecord
before_save :before_save_collection_association
define_non_cyclic_method(save_method) { save_collection_association(reflection) }
- after_save save_method
+ # Doesn't use after_save as that would save associations added in after_create/after_update twice
+ after_create save_method
+ after_update save_method
elsif reflection.has_one?
define_method(save_method) { save_has_one_association(reflection) } unless method_defined?(save_method)
# Configures two callbacks instead of a single after_save so that