aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCassioMarques <cassiommc@gmail.com>2008-11-07 23:51:45 -0200
committerCassioMarques <cassiommc@gmail.com>2008-11-07 23:51:45 -0200
commit4d122503bb7339d8d87fb54ae5f65ab30c17edd5 (patch)
treee621a8c2dc5e2859f192065909e3f83dd8b663f1
parent2cefcef8fef68cf1a7ecfd6a8325b63910d80e32 (diff)
downloadrails-4d122503bb7339d8d87fb54ae5f65ab30c17edd5.tar.gz
rails-4d122503bb7339d8d87fb54ae5f65ab30c17edd5.tar.bz2
rails-4d122503bb7339d8d87fb54ae5f65ab30c17edd5.zip
Added some aditional info to validates_confirmation_of
-rw-r--r--railties/doc/guides/html/activerecord_validations_callbacks.html18
-rw-r--r--railties/doc/guides/source/activerecord_validations_callbacks.txt10
2 files changed, 28 insertions, 0 deletions
diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html
index 0f03a7ebae..1f11ce4d08 100644
--- a/railties/doc/guides/html/activerecord_validations_callbacks.html
+++ b/railties/doc/guides/html/activerecord_validations_callbacks.html
@@ -408,6 +408,24 @@ http://www.gnu.org/software/src-highlite -->
<pre><tt>&lt;%= text_field :person, :email %&gt;
&lt;%= text_field :person, :email_confirmation %&gt;</tt></pre>
</div></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/note.png" alt="Note" />
+</td>
+<td class="content">This check is performed only if <tt>email_confirmation</tt> is not nil, and by default only on save. To require confirmation, make sure to add a presence check for the confirmation attribute:</td>
+</tr></table>
+</div>
+<div class="listingblock">
+<div class="content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Person <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
+ validates_confirmation_of <span style="color: #990000">:</span>email
+ validates_presence_of <span style="color: #990000">:</span>email_confirmation
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+</tt></pre></div></div>
<div class="para"><p>The default error message for <tt>validates_confirmation_of</tt> is "<em>doesn't match confirmation</em>"</p></div>
<h3 id="_the_tt_validates_each_tt_helper">3.4. The <tt>validates_each</tt> helper</h3>
<h3 id="_the_tt_validates_exclusion_of_tt_helper">3.5. The <tt>validates_exclusion_of</tt> helper</h3>
diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt
index ecbc093784..58e378ab24 100644
--- a/railties/doc/guides/source/activerecord_validations_callbacks.txt
+++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt
@@ -117,6 +117,16 @@ 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:
+
+[source, ruby]
+------------------------------------------------------------------
+class Person < ActiveRecord::Base
+ validates_confirmation_of :email
+ validates_presence_of :email_confirmation
+end
+------------------------------------------------------------------
+
The default error message for +validates_confirmation_of+ is "_doesn't match confirmation_"
=== The +validates_each+ helper