From a1e9ceebd59e9ac6b932f7ed5d35fe44eee6b93f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 21 May 2005 18:12:36 +0000 Subject: Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead. CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didnt before #1309. Added that " " is now also blank? (using strip if available) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1346 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/object_and_class.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/object_and_class.rb b/activesupport/lib/active_support/core_ext/object_and_class.rb index be486b0816..b8e9d27217 100644 --- a/activesupport/lib/active_support/core_ext/object_and_class.rb +++ b/activesupport/lib/active_support/core_ext/object_and_class.rb @@ -12,8 +12,11 @@ class Object #:nodoc: subclasses end + # "", " ", nil, and 0 are all blank def blank? - if respond_to? :empty? + if respond_to?(:empty?) && respond_to?(:strip) + strip.empty? + elsif respond_to? :empty? empty? elsif respond_to? :zero? zero? -- cgit v1.2.3