diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-06 15:30:49 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-06 15:30:49 -0300 |
commit | be1db9946616a4005bb7be45656cc0f84d75d915 (patch) | |
tree | af2ab5d030802db303e97799f443db3b0776d78b | |
parent | 6680ee9427ae2639e404cd3b9538f54e136057c6 (diff) | |
parent | ff7c015f171f777c140787f3591f6025254babe5 (diff) | |
download | rails-be1db9946616a4005bb7be45656cc0f84d75d915.tar.gz rails-be1db9946616a4005bb7be45656cc0f84d75d915.tar.bz2 rails-be1db9946616a4005bb7be45656cc0f84d75d915.zip |
Merge pull request #15550 from sgrif/sg-numeric-types
Don't mess with `_before_type_cast` for numeric types
-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: |