aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/dirty.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/dirty.rb')
-rw-r--r--activemodel/lib/active_model/dirty.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index d3a6bad6bb..57c594f159 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -86,6 +86,11 @@ module ActiveModel
attribute_method_affix :prefix => 'reset_', :suffix => '!'
end
+ def initialize(*)
+ @changed_attributes = {}
+ super
+ end
+
# Do any attributes have unsaved changes?
# person.changed? # => false
# person.name = 'bob'
@@ -107,7 +112,7 @@ module ActiveModel
# person.name = 'bob'
# person.changes # => { 'name' => ['bill', 'bob'] }
def changes
- changed.inject({}) { |h, attr| h[attr] = attribute_change(attr); h }
+ changed.inject(HashWithIndifferentAccess.new){ |h, attr| h[attr] = attribute_change(attr); h }
end
# Map of attributes that were changed when the model was saved.