aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJustin Mazzi <hh@mailheist.com>2011-11-05 22:36:19 -0400
committerJustin Mazzi <hh@mailheist.com>2011-11-05 22:36:19 -0400
commitc7d20785965d5f0877d0c13d0d9929f2fce50a8b (patch)
tree22a9f2da5f5667741438346857301469cd0f97d1 /activerecord/lib/active_record
parente7b7b4412380e7ce2d8e6ae402cb7fe02d7666b8 (diff)
downloadrails-c7d20785965d5f0877d0c13d0d9929f2fce50a8b.tar.gz
rails-c7d20785965d5f0877d0c13d0d9929f2fce50a8b.tar.bz2
rails-c7d20785965d5f0877d0c13d0d9929f2fce50a8b.zip
Update ActiveRecord#attribute_present? to work as documented
"Returns true if the specified attribute has been set by the user or by a database load and is neither nil nor empty?" Fixes #1613
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/base.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 455b299270..feeebb7131 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1771,7 +1771,8 @@ MSG
# 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 respond to empty?, most notably Strings).
def attribute_present?(attribute)
- !_read_attribute(attribute).blank?
+ value = _read_attribute(attribute)
+ !value.nil? || (value.respond_to?(:empty?) && !value.empty?)
end
# Returns the column object for the named attribute.