diff options
author | Xavier Noria <fxn@hashref.com> | 2011-03-14 21:59:58 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-03-14 22:03:23 +0100 |
commit | de5e41f855a8d715d99eec6195f9b31cc4048b99 (patch) | |
tree | b3356b4381414f302dbe6ee2150093063b61d421 /railties | |
parent | 9b64399684ded345e1006a0b5d54f94f5f44f121 (diff) | |
download | rails-de5e41f855a8d715d99eec6195f9b31cc4048b99.tar.gz rails-de5e41f855a8d715d99eec6195f9b31cc4048b99.tar.bz2 rails-de5e41f855a8d715d99eec6195f9b31cc4048b99.zip |
move the tips about :allow_(nil|blank) near their explanations, also no need to say these are options for all validators if they are not
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index bfb06a9cd5..e5349d546c 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -461,9 +461,7 @@ The block receives the model, the attribute's name and the attribute's value. Yo h3. Common Validation Options -There are some common options that all the validation helpers can use. Here they are, except for the +:if+ and +:unless+ options, which are discussed later in "Conditional Validation":#conditional-validation. - -TIP: Note that +allow_nil+ and +allow_blank+ will be ignored when using the presence validator. Please use the length validator if you want to validate if something is a specific length but allows for +nil+ values. +These are common validation options: h4. +:allow_nil+ @@ -476,6 +474,8 @@ class Coffee < ActiveRecord::Base end </ruby> +TIP: +:allow_nil+ is ignored by the presence validator. + h4. +:allow_blank+ The +:allow_blank+ option is similar to the +:allow_nil+ option. This option will let validation pass if the attribute's value is +blank?+, like +nil+ or an empty string for example. @@ -489,6 +489,8 @@ Topic.create("title" => "").valid? # => true Topic.create("title" => nil).valid? # => true </ruby> +TIP: +:allow_blank+ is ignored by the presence validator. + h4. +:message+ As you've already seen, 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. |