diff options
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 17f76b63b3..cf76d53bf7 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -350,6 +350,7 @@ module ActiveRecord end @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) + 1 @_start_transaction_state[:frozen?] = @attributes.frozen? + @_start_transaction_state[:changed_attributes] ||= changed_attributes end # Clear the new record state and id of a record. @@ -368,6 +369,9 @@ module ActiveRecord @attributes = @attributes.dup if @attributes.frozen? @new_record = restore_state[:new_record] @destroyed = restore_state[:destroyed] + changed_attributes.replace(restore_state[:changed_attributes]).delete_if do |attribute, old_value| + old_value == @attributes[attribute] + end if restore_state.has_key?(:id) write_attribute(self.class.primary_key, restore_state[:id]) else |