Skip to content
Browse files

r1618@asus: jeremy | 2005-07-03 08:24:19 -0700

 base attribute_present? on blank?, accounting for zero


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1636 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 67adc0b commit b210edce3830a62b75daef1d8b9e94f4160214dc @jeremy jeremy committed
Showing with 2 additions and 2 deletions.
  1. +2 −2 activerecord/lib/active_record/base.rb
View
4 activerecord/lib/active_record/base.rb
@@ -1079,8 +1079,8 @@ def attributes_before_type_cast
# Returns true if the specified +attribute+ has been set by the user or by a database load and is neither
# nil nor empty? (the latter only applies to objects that responds to empty?, most notably Strings).
def attribute_present?(attribute)
- is_empty = read_attribute(attribute).respond_to?("empty?") ? read_attribute(attribute).empty? : false
- @attributes.include?(attribute) && !@attributes[attribute].nil? && !is_empty
+ value = read_attribute(attribute)
+ !value.blank? or value == 0
end
# Returns an array of names for the attributes available on this object sorted alphabetically.

0 comments on commit b210edc

Please sign in to comment.
Something went wrong with that request. Please try again.