From b210edce3830a62b75daef1d8b9e94f4160214dc Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 3 Jul 2005 08:33:03 +0000 Subject: 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 --- activerecord/lib/active_record/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 0a844cc348..697e7a0c41 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1079,8 +1079,8 @@ module ActiveRecord #:nodoc: # 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. -- cgit v1.2.3