diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-06 17:33:08 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-06 17:33:08 -0300 |
commit | 43697f4fe5ce60d5483afbb2ccb123c4ed467022 (patch) | |
tree | 34681bebfa21afe12e43407800b24e7e693e60ec /activerecord/lib/active_record/type/numeric.rb | |
parent | 092f74080c85ae343fcd97ad5f88fb019ab421c0 (diff) | |
parent | 332d6c9b6ffdc6e4ca7886593256b5f994679316 (diff) | |
download | rails-43697f4fe5ce60d5483afbb2ccb123c4ed467022.tar.gz rails-43697f4fe5ce60d5483afbb2ccb123c4ed467022.tar.bz2 rails-43697f4fe5ce60d5483afbb2ccb123c4ed467022.zip |
Merge pull request #15551 from sgrif/sg-numeric-types
Don't mess with `_before_type_cast` for numeric types
Diffstat (limited to 'activerecord/lib/active_record/type/numeric.rb')
-rw-r--r-- | activerecord/lib/active_record/type/numeric.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/type/numeric.rb b/activerecord/lib/active_record/type/numeric.rb index 9cc6411e77..d5cb13233c 100644 --- a/activerecord/lib/active_record/type/numeric.rb +++ b/activerecord/lib/active_record/type/numeric.rb @@ -5,13 +5,14 @@ module ActiveRecord true end - def type_cast_for_write(value) - case value - when true then 1 - when false then 0 - when ::String then value.presence - else super - end + def type_cast(value) + value = case value + when true then 1 + when false then 0 + when ::String then value.presence + else value + end + super(value) end def changed?(old_value, new_value) # :nodoc: |