aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2018-03-06 15:09:34 -0700
committerSean Griffin <sean@seantheprogrammer.com>2018-03-06 15:11:23 -0700
commite126078a0e013acfe0a397a8dad33b2c9de78732 (patch)
tree3a027ded7961b0be33db66785d1f73795799f08b /activemodel
parent5fcbdcfb574c731841be12764c50d9587b58345f (diff)
downloadrails-e126078a0e013acfe0a397a8dad33b2c9de78732.tar.gz
rails-e126078a0e013acfe0a397a8dad33b2c9de78732.tar.bz2
rails-e126078a0e013acfe0a397a8dad33b2c9de78732.zip
Don't call changes in `changes_applied` unless required
This is an alternate implementation of #31698. That PR makes assumptions that I do not want in the code base. We can fix the performance regression with a much simpler patch.
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/dirty.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index d2ebd18107..eaf8dfb223 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -142,7 +142,9 @@ module ActiveModel
end
def changes_applied # :nodoc:
- @previously_changed = changes
+ unless defined?(@attributes)
+ @previously_changed = changes
+ end
@mutations_before_last_save = mutations_from_database
@attributes_changed_by_setter = ActiveSupport::HashWithIndifferentAccess.new
forget_attribute_assignments