diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-24 04:19:11 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-24 04:24:37 +0900 |
commit | 48e606f25af80cf1b774c659ed444322fa11106c (patch) | |
tree | ecc65c272834123df611006de707105da79faa12 /activerecord/lib | |
parent | b1458218c95d85c4ce911dd3e99da5ae7cf7aeee (diff) | |
download | rails-48e606f25af80cf1b774c659ed444322fa11106c.tar.gz rails-48e606f25af80cf1b774c659ed444322fa11106c.tar.bz2 rails-48e606f25af80cf1b774c659ed444322fa11106c.zip |
Simplify restore state condition
Follow up to b1458218c95d85c4ce911dd3e99da5ae7cf7aeee.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index dd6573873e..bf781b23eb 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -421,10 +421,8 @@ module ActiveRecord # Restore the new record state and id of a record that was previously saved by a call to save_record_state. def restore_transaction_record_state(force_restore_state = false) - if @_start_transaction_state - transaction_level = (@_start_transaction_state[:level] || 0) - 1 - if transaction_level < 1 || force_restore_state - restore_state = @_start_transaction_state + if restore_state = @_start_transaction_state + if force_restore_state || restore_state[:level] <= 1 @new_record = restore_state[:new_record] @destroyed = restore_state[:destroyed] @attributes = restore_state[:attributes].map do |attr| |