aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/doc/guides/html/activerecord_validations_callbacks.html21
-rw-r--r--railties/doc/guides/source/activerecord_validations_callbacks.txt19
2 files changed, 28 insertions, 12 deletions
diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html
index c82f428985..6feaae68ea 100644
--- a/railties/doc/guides/html/activerecord_validations_callbacks.html
+++ b/railties/doc/guides/html/activerecord_validations_callbacks.html
@@ -245,9 +245,6 @@ ul#navMain {
<a href="#_common_validation_options">Common validation options</a>
</li>
<li>
- <a href="#_credits">Credits</a>
- </li>
- <li>
<a href="#_changelog">Changelog</a>
</li>
</ol>
@@ -528,6 +525,19 @@ http://www.gnu.org/software/src-highlite -->
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
</tt></pre></div></div>
<h3 id="_the_tt_validates_numericallity_of_tt_helper">3.9. The <tt>validates_numericallity_of</tt> helper</h3>
+<div class="para"><p>This helper validates that your attributes have only numeric values. By default, it will match an optional sign followed by a integral or floating point number. Using the <tt>:integer_only</tt> option set to true, you can specify that only integral numbers are allowed.</p></div>
+<div class="para"><p>If you use <tt>:integer_only</tt> set to <tt>true</tt>, then it will use the <tt><span>/\A[+\-]?\d+\Z/</span></tt> regular expression to validate the attribute's value. Otherwise, it will try to convert the value using <tt>Kernel.Float</tt>.</p></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> Player <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
+ validates_numericallity_of <span style="color: #990000">:</span>points
+ validates_numericallity_of <span style="color: #990000">:</span>games_played<span style="color: #990000">,</span> <span style="color: #990000">:</span>integer_only <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span>
+<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_numericallity_of</tt> is "<em>is not a number</em>".</p></div>
<h3 id="_the_tt_validates_presence_of_tt_helper">3.10. The <tt>validates_presence_of</tt> helper</h3>
<h3 id="_the_tt_validates_size_of_tt_helper">3.11. The <tt>validates_size_of</tt> helper</h3>
<h3 id="_the_validates_uniqueness_of_helper">3.12. The validates_uniqueness_of+ helper</h3>
@@ -535,10 +545,7 @@ http://www.gnu.org/software/src-highlite -->
<h2 id="_common_validation_options">4. Common validation options</h2>
<div class="sectionbody">
</div>
-<h2 id="_credits">5. Credits</h2>
-<div class="sectionbody">
-</div>
-<h2 id="_changelog">6. Changelog</h2>
+<h2 id="_changelog">5. Changelog</h2>
<div class="sectionbody">
<div class="para"><p><a href="http://rails.lighthouseapp.com/projects/16213/tickets/26-active-record-validations-and-callbacks">http://rails.lighthouseapp.com/projects/16213/tickets/26-active-record-validations-and-callbacks</a></p></div>
</div>
diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt
index af82f62b6b..b26ebfed41 100644
--- a/railties/doc/guides/source/activerecord_validations_callbacks.txt
+++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt
@@ -221,18 +221,27 @@ end
=== The +validates_numericallity_of+ helper
-=== The +validates_presence_of+ helper
+This helper validates that your attributes have only numeric values. By default, it will match an optional sign followed by a integral or floating point number. Using the +:integer_only+ option set to true, you can specify that only integral numbers are allowed.
-=== The +validates_size_of+ helper
+If you use +:integer_only+ set to +true+, then it will use the +$$/\A[+\-]?\d+\Z/$$+ regular expression to validate the attribute's value. Otherwise, it will try to convert the value using +Kernel.Float+.
-=== The validates_uniqueness_of+ helper
+[source, ruby]
+------------------------------------------------------------------
+class Player < ActiveRecord::Base
+ validates_numericallity_of :points
+ validates_numericallity_of :games_played, :integer_only => true
+end
+------------------------------------------------------------------
-== Common validation options
+The default error message for +validates_numericallity_of+ is "_is not a number_".
+=== The +validates_presence_of+ helper
+=== The +validates_size_of+ helper
-== Credits
+=== The validates_uniqueness_of+ helper
+== Common validation options
== Changelog