aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-07 14:33:59 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-07 14:33:59 -0300
commit263774f045c7e7b76a60b9e71e907ed145757717 (patch)
treea2ab00340ab211f4a416212525ab3c6199e9b2ae /activerecord
parentdb5415dd4fa2c8cefd1197505f7c87dc0332e171 (diff)
parent35164093f5005c4312674bf3e00e2a92e2e3c7e5 (diff)
downloadrails-263774f045c7e7b76a60b9e71e907ed145757717.tar.gz
rails-263774f045c7e7b76a60b9e71e907ed145757717.tar.bz2
rails-263774f045c7e7b76a60b9e71e907ed145757717.zip
Merge pull request #15564 from sgrif/sg-remove-dead-code
Remove dead branch when restoring ID within a transaction Conflicts: activerecord/lib/active_record/transactions.rb
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/transactions.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index fec5d7f2ad..7e4dc4c895 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -339,7 +339,7 @@ module ActiveRecord
# Save the new record state and id of a record so it can be restored later if a transaction fails.
def remember_transaction_record_state #:nodoc:
- @_start_transaction_state[:id] = id if has_attribute?(self.class.primary_key)
+ @_start_transaction_state[:id] = id
unless @_start_transaction_state.include?(:new_record)
@_start_transaction_state[:new_record] = @new_record
end
@@ -370,12 +370,7 @@ module ActiveRecord
thaw unless restore_state[:frozen?]
@new_record = restore_state[:new_record]
@destroyed = restore_state[:destroyed]
- if restore_state.has_key?(:id)
- write_attribute(self.class.primary_key, restore_state[:id])
- else
- @raw_attributes.delete(self.class.primary_key)
- @attributes.delete(self.class.primary_key)
- end
+ write_attribute(self.class.primary_key, restore_state[:id])
end
end
end