aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorLawrence Pit <lawrence.pit@gmail.com>2010-01-07 19:53:15 +0100
committerEloy Duran <eloy.de.enige@gmail.com>2010-01-08 21:45:02 +0100
commit5193fe9dd730f9bbb72db055f37625fe9558b6ca (patch)
tree2f9391a569f5b14b75bcd7e244963c5248b4bf11 /activerecord/lib
parent1080351437dc43c3ecaa0d494f5ca215f03b1883 (diff)
downloadrails-5193fe9dd730f9bbb72db055f37625fe9558b6ca.tar.gz
rails-5193fe9dd730f9bbb72db055f37625fe9558b6ca.tar.bz2
rails-5193fe9dd730f9bbb72db055f37625fe9558b6ca.zip
Exclude unchanged records from the collection being considered for autosave. [#2578 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/autosave_association.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index f01d0903cd..741fb2ef40 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -224,10 +224,10 @@ module ActiveRecord
def associated_records_to_validate_or_save(association, new_record, autosave)
if new_record
association
- elsif association.loaded?
- autosave ? association : association.find_all { |record| record.new_record? }
+ elsif autosave
+ association.target.find_all { |record| record.new_record? || record.changed? || record.marked_for_destruction? }
else
- autosave ? association.target : association.target.find_all { |record| record.new_record? }
+ association.target.find_all { |record| record.new_record? }
end
end