aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-19 17:21:06 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-19 17:21:06 -0300
commitefb41c6abc39b71183d3f13a267f801576a399cb (patch)
tree498f59ddbf51a90a3ca9bc368701c8191df8d3d9 /activerecord/lib
parent1fa3a241c2485654f3cfa2287c19cd6785d265d9 (diff)
parent068f092ced8483e557725542dd919ab7c516e567 (diff)
downloadrails-efb41c6abc39b71183d3f13a267f801576a399cb.tar.gz
rails-efb41c6abc39b71183d3f13a267f801576a399cb.tar.bz2
rails-efb41c6abc39b71183d3f13a267f801576a399cb.zip
Merge pull request #15728 from sgrif/sg-double-save-hm-t
Don't save through records twice Conflicts: activerecord/CHANGELOG.md activerecord/test/cases/associations/has_many_through_associations_test.rb
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index b3c3e26c9f..dd92e29199 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -184,9 +184,7 @@ module ActiveRecord
before_save :before_save_collection_association
define_non_cyclic_method(save_method) { save_collection_association(reflection) }
- # 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
+ after_save 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
@@ -364,6 +362,7 @@ module ActiveRecord
raise ActiveRecord::Rollback unless saved
end
+ @new_record_before_save = false
end
# reconstruct the scope now that we know the owner's id