From 81286f858770e0b95e15af37f19156b044ec6a95 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 29 Mar 2008 22:19:26 +0000 Subject: Dirty typecasts attribute values before comparison, if possible. Closes #11464 [Russell Norris, mroch] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9139 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/dirty.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/dirty.rb b/activerecord/lib/active_record/dirty.rb index a9ae2b148c..4b65545851 100644 --- a/activerecord/lib/active_record/dirty.rb +++ b/activerecord/lib/active_record/dirty.rb @@ -91,7 +91,12 @@ module ActiveRecord old = read_attribute(attr) # Remember the original value if it's different. - changed_attributes[attr] = old unless old == value + typecasted = if column = column_for_attribute(attr) + column.type_cast(value) + else + value + end + changed_attributes[attr] = old unless old == typecasted end # Carry on. -- cgit v1.2.3