Skip to content
This repository
Browse code

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
  • Loading branch information...
commit de5e41f855a8d715d99eec6195f9b31cc4048b99 1 parent 9b64399
Xavier Noria fxn authored
8 railties/guides/source/active_record_validations_callbacks.textile
Source Rendered
@@ -461,9 +461,7 @@ The block receives the model, the attribute's name and the attribute's value. Yo
461 461
462 462 h3. Common Validation Options
463 463
464   -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.
465   -
466   -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.
  464 +These are common validation options:
467 465
468 466 h4. +:allow_nil+
469 467
@@ -476,6 +474,8 @@ class Coffee < ActiveRecord::Base
476 474 end
477 475 </ruby>
478 476
  477 +TIP: +:allow_nil+ is ignored by the presence validator.
  478 +
479 479 h4. +:allow_blank+
480 480
481 481 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
489 489 Topic.create("title" => nil).valid? # => true
490 490 </ruby>
491 491
  492 +TIP: +:allow_blank+ is ignored by the presence validator.
  493 +
492 494 h4. +:message+
493 495
494 496 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.

0 comments on commit de5e41f

Please sign in to comment.
Something went wrong with that request. Please try again.