aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-21 18:12:36 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-21 18:12:36 +0000
commita1e9ceebd59e9ac6b932f7ed5d35fe44eee6b93f (patch)
treef907e976a5d0093bea013a98422dee2efd97e4d8 /activesupport
parent7159402c6d0edab20ff84a686bcd03894b4e9c4c (diff)
downloadrails-a1e9ceebd59e9ac6b932f7ed5d35fe44eee6b93f.tar.gz
rails-a1e9ceebd59e9ac6b932f7ed5d35fe44eee6b93f.tar.bz2
rails-a1e9ceebd59e9ac6b932f7ed5d35fe44eee6b93f.zip
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
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/object_and_class.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index ac3e9eb7e5..2c70cecc2b 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added that " " is now also blank? (using strip if available)
+
* Fixed Dependencies so all modules are able to load missing constants #1173 [Nicholas Seckar]
* Fixed the Inflector to underscore strings containing numbers, so Area51Controller becomes area51_controller #1176 [Nicholas Seckar]
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?