diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-07-03 08:33:03 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-07-03 08:33:03 +0000 |
commit | b210edce3830a62b75daef1d8b9e94f4160214dc (patch) | |
tree | 4765498beb4467d3543b5f2281c97ea7269e3cdf /activerecord/lib | |
parent | 67adc0b5b3a0ba5b91866d6b24f4487bf625ea2b (diff) | |
download | rails-b210edce3830a62b75daef1d8b9e94f4160214dc.tar.gz rails-b210edce3830a62b75daef1d8b9e94f4160214dc.tar.bz2 rails-b210edce3830a62b75daef1d8b9e94f4160214dc.zip |
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
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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. |