diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-06 16:02:39 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-06 16:02:39 -0300 |
commit | a0aebc0dfbe9ba35fde0f64b8907664d8cef84a3 (patch) | |
tree | 15a7a0164bd967195114f59ff638f9005d426c2c | |
parent | be1db9946616a4005bb7be45656cc0f84d75d915 (diff) | |
download | rails-a0aebc0dfbe9ba35fde0f64b8907664d8cef84a3.tar.gz rails-a0aebc0dfbe9ba35fde0f64b8907664d8cef84a3.tar.bz2 rails-a0aebc0dfbe9ba35fde0f64b8907664d8cef84a3.zip |
Revert "Merge pull request #15550 from sgrif/sg-numeric-types"
This reverts commit be1db9946616a4005bb7be45656cc0f84d75d915, reversing
changes made to 6680ee9427ae2639e404cd3b9538f54e136057c6.
Reason: This changed a behavior where numeric attributes when receiving
blank values didn't change its value.
-rw-r--r-- | activerecord/lib/active_record/type/numeric.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/type/numeric.rb b/activerecord/lib/active_record/type/numeric.rb index d5cb13233c..9cc6411e77 100644 --- a/activerecord/lib/active_record/type/numeric.rb +++ b/activerecord/lib/active_record/type/numeric.rb @@ -5,14 +5,13 @@ module ActiveRecord true 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) + def type_cast_for_write(value) + case value + when true then 1 + when false then 0 + when ::String then value.presence + else super + end end def changed?(old_value, new_value) # :nodoc: |