From a0aebc0dfbe9ba35fde0f64b8907664d8cef84a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 6 Jun 2014 16:02:39 -0300 Subject: 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. --- activerecord/lib/active_record/type/numeric.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/type/numeric.rb') 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: -- cgit v1.2.3