From ff7c015f171f777c140787f3591f6025254babe5 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 6 Jun 2014 12:28:22 -0600 Subject: Don't mess with `_before_type_cast` for numeric types --- activerecord/lib/active_record/type/numeric.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 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: -- cgit v1.2.3