diff options
author | Jeff Kreeftmeijer <jeff@kreeftmeijer.nl> | 2011-03-09 10:58:18 +0100 |
---|---|---|
committer | Jeff Kreeftmeijer <jeff@kreeftmeijer.nl> | 2011-03-09 10:58:18 +0100 |
commit | e05e9979075b37342b7c88e557dbffd672b2086a (patch) | |
tree | 7f6e1880a91390b4e4dad6531dd53cd9ed835cd6 | |
parent | 9798ee2619154de5b2f052735d1ec80c47857178 (diff) | |
download | rails-e05e9979075b37342b7c88e557dbffd672b2086a.tar.gz rails-e05e9979075b37342b7c88e557dbffd672b2086a.tar.bz2 rails-e05e9979075b37342b7c88e557dbffd672b2086a.zip |
Add a note to discourage users from using presence validators with allow_(nil|blank)
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 58a184a48e..2301d6715d 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -463,9 +463,11 @@ 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. + h4. +:allow_nil+ -The +:allow_nil+ option skips the validation when the value being validated is +nil+. Using +:allow_nil+ with +validates_presence_of+ allows for +nil+, but any other +blank?+ value will still be rejected. +The +:allow_nil+ option skips the validation when the value being validated is +nil+. <ruby> class Coffee < ActiveRecord::Base |