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

add destroyed records to the currend transaction

This commit is contained in:
Aaron Patterson 2015-02-01 14:20:36 -08:00
parent 045c77c1bc
commit 58410b3d56
2 changed files with 5 additions and 1 deletions

View file

@ -178,6 +178,7 @@ module ActiveRecord
def destroy
raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
destroy_associations
self.class.connection.add_transaction_record(self)
destroy_row if persisted?
@destroyed = true
freeze

View file

@ -381,7 +381,10 @@ module ActiveRecord
thaw unless restore_state[:frozen?]
@new_record = restore_state[:new_record]
@destroyed = restore_state[:destroyed]
write_attribute(self.class.primary_key, restore_state[:id]) if self.class.primary_key
pk = self.class.primary_key
if pk && read_attribute(pk) != restore_state[:id]
write_attribute(pk, restore_state[:id])
end
end
end
end