Permalink
Browse files

Small modifications in the text of the section about using the errors…

… collection in the view, fixed a typo at the validates_numericality_of section
  • Loading branch information...
1 parent 301b2fe commit 51460808cd1f0beaec8d862dc6ee8ca8aad27ed6 @cassiomarques cassiomarques committed Jan 15, 2009
View
6 railties/doc/guides/html/activerecord_validations_callbacks.html
@@ -602,15 +602,15 @@ <h3 id="_the_tt_validates_length_of_tt_helper">2.7. The <tt>validates_length_of<
<div class="paragraph"><p>The <tt>validates_size_of</tt> helper is an alias for <tt>validates_length_of</tt>.</p></div>
<h3 id="_the_tt_validates_numericality_of_tt_helper">2.8. The <tt>validates_numericality_of</tt> helper</h3>
<div class="paragraph"><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="paragraph"><p>If you set <tt>:integer_only</tt> to <tt>true</tt>, then it will use the <tt>/\A[+\-]?\d+\Z/+ regular expression to validate the attribute&#8217;s value. Otherwise, it will try to convert the value to a number using +Kernel.Float</tt>.</p></div>
+<div class="paragraph"><p>If you set <tt>:integer_only</tt> to <tt>true</tt>, then it will use the <tt>$$/\A[</tt>\-]?\d+\Z/<tt> regular expression to validate the attribute&#8217;s value. Otherwise, it will try to convert the value to a number using +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_numericality_of <span style="color: #990000">:</span>points
- validates_numericality_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>
+ validates_numericality_of <span style="color: #990000">:</span>games_played<span style="color: #990000">,</span> <span style="color: #990000">:</span>only_integer <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="paragraph"><p>Besides <tt>:only_integer</tt>, the <tt>validates_numericality_of</tt> helper also accepts the following options to add constraints to acceptable values:</p></div>
<div class="ulist"><ul>
@@ -983,7 +983,7 @@ <h2 id="_manipulating_the_tt_errors_tt_collection">6. Manipulating the <tt>error
</div>
<h2 id="_using_the_tt_errors_tt_collection_in_your_view_templates">7. Using the <tt>errors</tt> collection in your view templates</h2>
<div class="sectionbody">
-<div class="paragraph"><p>Rails provides built-in helpers to display the error messages of your models in your view templates. It may be useful to display those messages when you&#8217;re trying to create or edit a record and validation fails. If you&#8217;re using the <tt>form_for</tt> helper to create a form, you can use it to call the <tt>error_messages</tt> method, which creates a <tt>div</tt> element containing all the error messages for the model associated with the form. Here is a simple example, using a <tt>Product</tt> model and the view template generated with the scaffold script.</p></div>
+<div class="paragraph"><p>Rails provides built-in helpers to display the error messages of your models in your view templates. When creating a form with the form_for helper, you can use the error_messages method on the form builder to render all failed validation messages for the current model instance.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
View
4 railties/doc/guides/source/activerecord_validations_callbacks.txt
@@ -217,7 +217,7 @@ The +validates_size_of+ helper is an alias for +validates_length_of+.
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.
-If you set +:integer_only+ 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 to a number using +Kernel.Float+.
+If you set +:integer_only+ 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 to a number using +Kernel.Float+.
[source, ruby]
------------------------------------------------------------------
@@ -542,7 +542,7 @@ p.errors.on(:name)
== Using the +errors+ collection in your view templates
-Rails provides built-in helpers to display the error messages of your models in your view templates. It may be useful to display those messages when you're trying to create or edit a record and validation fails. If you're using the +form_for+ helper to create a form, you can use it to call the +error_messages+ method, which creates a +div+ element containing all the error messages for the model associated with the form. Here is a simple example, using a +Product+ model and the view template generated with the scaffold script.
+Rails provides built-in helpers to display the error messages of your models in your view templates. When creating a form with the form_for helper, you can use the error_messages method on the form builder to render all failed validation messages for the current model instance.
[source, ruby]
------------------------------------------------------------------

0 comments on commit 5146080

Please sign in to comment.