aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/html/activerecord_validations_callbacks.html
diff options
context:
space:
mode:
authorCassioMarques <cassiommc@gmail.com>2008-11-10 20:31:05 -0200
committerCassioMarques <cassiommc@gmail.com>2008-11-10 20:31:05 -0200
commitd0cb4d7258c9241fcffda854d615c44586189838 (patch)
tree4d6858e2080d0ff26d20956c5207ea7ff8e618e6 /railties/doc/guides/html/activerecord_validations_callbacks.html
parent0668ab67bf6b32950113995303446840ae57d5d9 (diff)
downloadrails-d0cb4d7258c9241fcffda854d615c44586189838.tar.gz
rails-d0cb4d7258c9241fcffda854d615c44586189838.tar.bz2
rails-d0cb4d7258c9241fcffda854d615c44586189838.zip
Added note about testing booleans to validates_presence_of
Diffstat (limited to 'railties/doc/guides/html/activerecord_validations_callbacks.html')
-rw-r--r--railties/doc/guides/html/activerecord_validations_callbacks.html8
1 files changed, 8 insertions, 0 deletions
diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html
index 2e5044eb6e..6953c3979a 100644
--- a/railties/doc/guides/html/activerecord_validations_callbacks.html
+++ b/railties/doc/guides/html/activerecord_validations_callbacks.html
@@ -567,6 +567,14 @@ http://www.gnu.org/software/src-highlite -->
validates_presence_of <span style="color: #990000">:</span>order_id
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
</tt></pre></div></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/note.png" alt="Note" />
+</td>
+<td class="content">If you want to validate the presence of a boolean field (where the real values are true and false), you will want to use validates_inclusion_of :field_name, :in &#8658; [true, false] This is due to the way Object#blank? handles boolean values. false.blank? # &#8658; true</td>
+</tr></table>
+</div>
<div class="para"><p>The default error message for <tt>validates_presence_of</tt> is "<em>can't be empty</em>".</p></div>
<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>