diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2013-05-24 13:02:19 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-05-24 13:02:19 +0100 |
commit | 8799cfa72d071fe6ce78fa7dbbf5dd3c9d763a68 (patch) | |
tree | f8647ae0aa8dae4ba37ec18d7213c8277f4b83f0 | |
parent | 7101a857b46e1c8aa3b9dd9641c4fc5b28a143e6 (diff) | |
download | rails-8799cfa72d071fe6ce78fa7dbbf5dd3c9d763a68.tar.gz rails-8799cfa72d071fe6ce78fa7dbbf5dd3c9d763a68.tar.bz2 rails-8799cfa72d071fe6ce78fa7dbbf5dd3c9d763a68.zip |
Restore rescue block for when IM is enabled
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 7bc103043e..3fc9d307bc 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -331,28 +331,31 @@ module ActiveRecord autosave = reflection.options[:autosave] if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave) + begin + if autosave + records_to_destroy = records.select(&:marked_for_destruction?) + records_to_destroy.each { |record| association.proxy.destroy(record) } + records -= records_to_destroy + end - if autosave - records_to_destroy = records.select(&:marked_for_destruction?) - records_to_destroy.each { |record| association.proxy.destroy(record) } - records -= records_to_destroy - end - - records.each do |record| - - saved = true - - if autosave != false && (@new_record_before_save || record.new_record?) - if autosave - saved = association.insert_record(record, false) - else - association.insert_record(record) unless reflection.nested? + records.each do |record| + saved = true + + if autosave != false && (@new_record_before_save || record.new_record?) + if autosave + saved = association.insert_record(record, false) + else + association.insert_record(record) unless reflection.nested? + end + elsif autosave + saved = record.save(:validate => false) end - elsif autosave - saved = record.save(:validate => false) - end - raise ActiveRecord::Rollback unless saved + raise ActiveRecord::Rollback unless saved + end + rescue + records.each {|x| IdentityMap.remove(x) } if IdentityMap.enabled? + raise end end |