diff options
author | Philipp Fehre <philipp@fehre.co.uk> | 2015-09-15 19:41:03 +0100 |
---|---|---|
committer | Philipp Fehre <philipp@fehre.co.uk> | 2015-09-15 19:41:03 +0100 |
commit | 7cd6a28c783ce8464bb2061f7cbc4989b6985ad8 (patch) | |
tree | 682965ecb6b83544d1c3b7db17cdd4455a0b5bbd /activerecord | |
parent | 9347538312ba796ac698f06068b213ed17924e08 (diff) | |
download | rails-7cd6a28c783ce8464bb2061f7cbc4989b6985ad8.tar.gz rails-7cd6a28c783ce8464bb2061f7cbc4989b6985ad8.tar.bz2 rails-7cd6a28c783ce8464bb2061f7cbc4989b6985ad8.zip |
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`.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attributes.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |