aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source
diff options
context:
space:
mode:
authorCassioMarques <cassiommc@gmail.com>2009-01-08 21:16:42 -0200
committerCassioMarques <cassiommc@gmail.com>2009-01-08 21:16:42 -0200
commit79eba81df8177685575f06a098325424a0c8dfd0 (patch)
treeec2db7c9311c574a723b23b583905d9ac41db383 /railties/doc/guides/source
parentafdacd0857886a021ff68e8238876daec82efefb (diff)
downloadrails-79eba81df8177685575f06a098325424a0c8dfd0.tar.gz
rails-79eba81df8177685575f06a098325424a0c8dfd0.tar.bz2
rails-79eba81df8177685575f06a098325424a0c8dfd0.zip
Added :allow_blank to the common validation options section
Diffstat (limited to 'railties/doc/guides/source')
-rw-r--r--railties/doc/guides/source/activerecord_validations_callbacks.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt
index 9865aeebb0..7d37df1ed2 100644
--- a/railties/doc/guides/source/activerecord_validations_callbacks.txt
+++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt
@@ -317,6 +317,20 @@ class Coffee < ActiveRecord::Base
end
------------------------------------------------------------------
+=== The +:allow_blank+ option
+
+In compliment to +:allow_nil+ we have +:allow_blank+. This option will let validation pass if the attribute's value is +nil+ or an empty string, i.e., any value that returns +true+ for +blank?+.
+
+[source, ruby]
+------------------------------------------------------------------
+class Topic < ActiveRecord::Base
+ validates_length_of :title, :is => 5, :allow_blank => true
+end
+
+Topic.create("title" => "").valid? # => true
+Topic.create("title" => nil).valid? # => true
+------------------------------------------------------------------
+
=== The +:message+ option
As stated before, the +:message+ option lets you specify the message that will be added to the +errors+ collection when validation fails. When this option is not used, Active Record will use the respective default error message for each validation helper.