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:
parent
09f12a1270
commit
7df61754a5
1 changed files with 18 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue