1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove associated records from identity map if any raised an unexpected exception.

This commit is contained in:
Emilio Tagua 2010-09-13 14:56:42 -03:00
parent 09f12a1270
commit 7df61754a5

View file

@ -320,6 +320,7 @@ module ActiveRecord
autosave = reflection.options[:autosave]
if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave)
begin
records.each do |record|
next if record.destroyed?
@ -337,6 +338,10 @@ module ActiveRecord
raise ActiveRecord::Rollback if saved == false
end
rescue
records.each {|x| IdentityMap.remove(x) } if IdentityMap.enabled?
raise
end
end
# reconstruct the scope now that we know the owner's id