1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #6804 from acapilleri/firm_changes_from_zero_to_string

changed the firm of changes_from_zero_to_string?
This commit is contained in:
Carlos Antonio da Silva 2012-06-21 05:37:36 -07:00
commit e76ced0620

View file

@ -78,7 +78,7 @@ module ActiveRecord
def _field_changed?(attr, old, value)
if column = column_for_attribute(attr)
if column.number? && (changes_from_nil_to_empty_string?(column, old, value) ||
changes_from_zero_to_string?(column, old, value))
changes_from_zero_to_string?(old, value))
value = nil
else
value = column.type_cast(value)
@ -96,7 +96,7 @@ module ActiveRecord
column.null && (old.nil? || old == 0) && value.blank?
end
def changes_from_zero_to_string?(column, old, value)
def changes_from_zero_to_string?(old, value)
# For columns with old 0 and value non-empty string
old == 0 && value.present? && value != '0'
end