diff options
author | CassioMarques <cassiommc@gmail.com> | 2008-11-07 23:59:36 -0200 |
---|---|---|
committer | CassioMarques <cassiommc@gmail.com> | 2008-11-07 23:59:36 -0200 |
commit | 30a789429948886f0ef7d8204420277c68ab4d18 (patch) | |
tree | f347706a2436933bf9e7f3c129d6273f991c494a /railties/doc/guides/source/activerecord_validations_callbacks.txt | |
parent | 4d122503bb7339d8d87fb54ae5f65ab30c17edd5 (diff) | |
download | rails-30a789429948886f0ef7d8204420277c68ab4d18.tar.gz rails-30a789429948886f0ef7d8204420277c68ab4d18.tar.bz2 rails-30a789429948886f0ef7d8204420277c68ab4d18.zip |
Some more text on validates_confirmation_of, added some more about validations helpers too
Diffstat (limited to 'railties/doc/guides/source/activerecord_validations_callbacks.txt')
-rw-r--r-- | railties/doc/guides/source/activerecord_validations_callbacks.txt | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt index 58e378ab24..f05628302d 100644 --- a/railties/doc/guides/source/activerecord_validations_callbacks.txt +++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt @@ -57,6 +57,8 @@ For verifying if an object is valid, Active Record uses the +valid?+ method, whi Active Record offers many pre-defined validation helpers that you can use directly inside your class definitions. These helpers create validations rules that are commonly used in most of the applications that you'll write, so you don't need to recreate it everytime, avoiding code duplication, keeping everything organized and boosting your productivity. Everytime a validation fails, an error message is added to the object's +errors+ collection, this message being associated with the field being validated. +Each helper accepts an arbitrary number of attributes, received as symbols, so with a single line of code you can add the same kind of validation to several attributes. + All these helpers accept the +:on+ and +:message+ options, which define when the validation should be applied and what message should be added to the +errors+ collection when it fails, respectively. The +:on+ option takes one the values +:save+ (it's the default), +:create+ or +:update+. There is a default error message for each one of the validation helpers. These messages are used when the +:message+ option isn't used. Let's take a look at each one of the available helpers, listed in alphabetic order. === The +validates_acceptance_of+ helper @@ -117,7 +119,7 @@ In your view template you could use something like <%= text_field :person, :email_confirmation %> ------------------------------------------------------------------ -NOTE: This check is performed only if +email_confirmation+ is not nil, and by default only on save. To require confirmation, make sure to add a presence check for the confirmation attribute: +NOTE: This check is performed only if +email_confirmation+ is not nil, and by default only on save. To require confirmation, make sure to add a presence check for the confirmation attribute (we'll take a look at +validates_presence_of+ later on this guide): [source, ruby] ------------------------------------------------------------------ |