aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/transactions.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-02-01 14:20:36 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2015-02-01 14:20:36 -0800
commit58410b3d566e6b93c7b71c0eec0fc11ec906b68e (patch)
tree3f84c6b8bf66468a871263ab7c9b822ad3121b56 /activerecord/lib/active_record/transactions.rb
parent045c77c1bc8f9acdc7efe34ba7af59acfe6f955f (diff)
downloadrails-58410b3d566e6b93c7b71c0eec0fc11ec906b68e.tar.gz
rails-58410b3d566e6b93c7b71c0eec0fc11ec906b68e.tar.bz2
rails-58410b3d566e6b93c7b71c0eec0fc11ec906b68e.zip
add destroyed records to the currend transaction
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r--activerecord/lib/active_record/transactions.rb5
1 files changed, 4 insertions, 1 deletions
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