From 0e655873d4f41922fa2614919342482b1dbd2343 Mon Sep 17 00:00:00 2001 From: William Myers Date: Mon, 7 Jan 2013 00:04:35 -0500 Subject: DirtyModel uses a hash to keep track of any changes made to attributes of an instance. When using the attribute_will_change! method, you must supply a string and not a symbol or the *_changed? method will break (because it is looking for the attribute name as a string in the keys of the underlying hash). To remedy this, I simply made the underlying hash a HashWithIndifferentAccess so it won't matter if you supply the attribute name as a symbol or string to attribute_will_change!. --- activemodel/lib/active_model/dirty.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index 6e67cd2285..b89b98feed 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -139,7 +139,7 @@ module ActiveModel # person.name = 'robert' # person.changed_attributes # => {"name" => "bob"} def changed_attributes - @changed_attributes ||= {} + @changed_attributes ||= ActiveSupport::HashWithIndifferentAccess.new end private -- cgit v1.2.3