From 58410b3d566e6b93c7b71c0eec0fc11ec906b68e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 1 Feb 2015 14:20:36 -0800 Subject: add destroyed records to the currend transaction --- activerecord/lib/active_record/transactions.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/transactions.rb') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 609c395cb6..dd405c7796 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -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 -- cgit v1.2.3