Skip to content

Commit

Permalink
Merge pull request rails#6804 from acapilleri/firm_changes_from_zero_…
Browse files Browse the repository at this point in the history
…to_string

changed the firm of changes_from_zero_to_string?
  • Loading branch information
carlosantoniodasilva committed Jun 21, 2012
2 parents 682d247 + c3a5be0 commit e76ced0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/attribute_methods/dirty.rb
Expand Up @@ -78,7 +78,7 @@ def update(*)
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)
Expand All @@ -96,7 +96,7 @@ def changes_from_nil_to_empty_string?(column, old, value)
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
Expand Down

0 comments on commit e76ced0

Please sign in to comment.