diff options
Diffstat (limited to 'activerecord/lib/active_record/type')
-rw-r--r-- | activerecord/lib/active_record/type/numeric.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/serialized.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/value.rb | 4 |
3 files changed, 5 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/type/numeric.rb b/activerecord/lib/active_record/type/numeric.rb index d5cb13233c..137c9e4c99 100644 --- a/activerecord/lib/active_record/type/numeric.rb +++ b/activerecord/lib/active_record/type/numeric.rb @@ -15,11 +15,11 @@ module ActiveRecord super(value) end - def changed?(old_value, new_value) # :nodoc: + def changed?(old_value, _new_value, new_value_before_type_cast) # :nodoc: # 0 => 'wibble' should mark as changed so numericality validations run - if nil_or_zero?(old_value) && non_numeric_string?(new_value) + if nil_or_zero?(old_value) && non_numeric_string?(new_value_before_type_cast) # nil => '' should not mark as changed - old_value != new_value.presence + old_value != new_value_before_type_cast.presence else super end diff --git a/activerecord/lib/active_record/type/serialized.rb b/activerecord/lib/active_record/type/serialized.rb index 94d9d9a549..0866383de9 100644 --- a/activerecord/lib/active_record/type/serialized.rb +++ b/activerecord/lib/active_record/type/serialized.rb @@ -36,10 +36,6 @@ module ActiveRecord private - def changed?(old_value, new_value) # :nodoc: - old_value != new_value - end - def is_default_value?(value) value == coder.load(nil) end diff --git a/activerecord/lib/active_record/type/value.rb b/activerecord/lib/active_record/type/value.rb index 4bc3086db3..1c41b28646 100644 --- a/activerecord/lib/active_record/type/value.rb +++ b/activerecord/lib/active_record/type/value.rb @@ -59,8 +59,8 @@ module ActiveRecord # or from assignment, so it could be anything. Types # which cannot typecast arbitrary values should override # this method. - def changed?(old_value, new_value) # :nodoc: - old_value != type_cast(new_value) + def changed?(old_value, new_value, _new_value_before_type_cast) # :nodoc: + old_value != new_value end private |