From 7cd6a28c783ce8464bb2061f7cbc4989b6985ad8 Mon Sep 17 00:00:00 2001 From: Philipp Fehre Date: Tue, 15 Sep 2015 19:41:03 +0100 Subject: ActiveRecord Attributes API code fix I came across this while trying it out, with the provided code the `MoneyType` does not save as it complains that `Fixnum` does not define `include?`. I think the sensible thing is to check if it already is a `Numeric`. --- activerecord/lib/active_record/attributes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/attributes.rb b/activerecord/lib/active_record/attributes.rb index 8b2c4c7170..9cfc58dfa0 100644 --- a/activerecord/lib/active_record/attributes.rb +++ b/activerecord/lib/active_record/attributes.rb @@ -122,7 +122,7 @@ module ActiveRecord # # class MoneyType < ActiveRecord::Type::Integer # def cast(value) - # if value.include?('$') + # if !value.kind_of(Numeric) && value.include?('$') # price_in_dollars = value.gsub(/\$/, '').to_f # super(price_in_dollars * 100) # else -- cgit v1.2.3