diff options
-rw-r--r-- | activemodel/lib/active_model/dirty.rb | 5 | ||||
-rw-r--r-- | activemodel/test/cases/dirty_test.rb | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index 2f6b30dfed..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' diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb index c910cb43d4..0883363baf 100644 --- a/activemodel/test/cases/dirty_test.rb +++ b/activemodel/test/cases/dirty_test.rb @@ -6,6 +6,7 @@ class DirtyTest < ActiveModel::TestCase define_attribute_methods [:name] def initialize + super @name = nil end |