From 2cefcef8fef68cf1a7ecfd6a8325b63910d80e32 Mon Sep 17 00:00:00 2001 From: CassioMarques Date: Fri, 7 Nov 2008 23:28:21 -0200 Subject: Added documentation for validates_confirmation_of --- .../guides/html/activerecord_validations_callbacks.html | 17 +++++++++++++++++ .../source/activerecord_validations_callbacks.txt | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'railties/doc') diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html index 7125b7252f..0f03a7ebae 100644 --- a/railties/doc/guides/html/activerecord_validations_callbacks.html +++ b/railties/doc/guides/html/activerecord_validations_callbacks.html @@ -392,6 +392,23 @@ http://www.gnu.org/software/src-highlite -->

The default error message for validates_associated is "is invalid". Note that the errors for each failed validation in the associated objects will be set there and not in this model.

3.3. The validates_confirmation_of helper

+

You should use this helper when you have two text fields that should receive exactly the same content, like when you want to confirm an email address or password. This validation creates a virtual attribute, using the name of the field that has to be confirmed with _confirmation appended.

+
+
+
class Person < ActiveRecord::Base
+  validates_confirmation_of :email
+end
+
+

In your view template you could use something like

+
+
+
<%= text_field :person, :email %>
+<%= text_field :person, :email_confirmation %>
+
+

The default error message for validates_confirmation_of is "doesn't match confirmation"

3.4. The validates_each helper

3.5. The validates_exclusion_of helper

3.6. The validates_format_of helper

diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt index eaf7b428ba..ecbc093784 100644 --- a/railties/doc/guides/source/activerecord_validations_callbacks.txt +++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt @@ -102,6 +102,23 @@ The default error message for +validates_associated+ is "_is invalid_". Note tha === The +validates_confirmation_of+ helper +You should use this helper when you have two text fields that should receive exactly the same content, like when you want to confirm an email address or password. This validation creates a virtual attribute, using the name of the field that has to be confirmed with '_confirmation' appended. + +[source, ruby] +------------------------------------------------------------------ +class Person < ActiveRecord::Base + validates_confirmation_of :email +end +------------------------------------------------------------------ + +In your view template you could use something like +------------------------------------------------------------------ +<%= text_field :person, :email %> +<%= text_field :person, :email_confirmation %> +------------------------------------------------------------------ + +The default error message for +validates_confirmation_of+ is "_doesn't match confirmation_" + === The +validates_each+ helper === The +validates_exclusion_of+ helper -- cgit v1.2.3