diff options
author | CassioMarques <cassiommc@gmail.com> | 2008-11-18 19:14:51 -0200 |
---|---|---|
committer | CassioMarques <cassiommc@gmail.com> | 2008-11-18 19:16:01 -0200 |
commit | b60971ad6b19a3cd72a972b459e94059d24c0848 (patch) | |
tree | f5b4ba2da11b06cd1844aa88ad53e5cb76dbe49b /railties/doc/guides/html/activerecord_validations_callbacks.html | |
parent | 64e8f14058949b0b1967a4d1282c6fc154e890e9 (diff) | |
download | rails-b60971ad6b19a3cd72a972b459e94059d24c0848.tar.gz rails-b60971ad6b19a3cd72a972b459e94059d24c0848.tar.bz2 rails-b60971ad6b19a3cd72a972b459e94059d24c0848.zip |
Added note about update_attribute not triggering validation
Diffstat (limited to 'railties/doc/guides/html/activerecord_validations_callbacks.html')
-rw-r--r-- | railties/doc/guides/html/activerecord_validations_callbacks.html | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/railties/doc/guides/html/activerecord_validations_callbacks.html b/railties/doc/guides/html/activerecord_validations_callbacks.html index b6cb481eab..097ef706ca 100644 --- a/railties/doc/guides/html/activerecord_validations_callbacks.html +++ b/railties/doc/guides/html/activerecord_validations_callbacks.html @@ -362,6 +362,14 @@ http://www.gnu.org/software/src-highlite --> => false</tt></pre>
</div></div>
<div class="para"><p>Saving new records means sending an SQL insert operation to the database, while saving existing records (by calling either <tt>save</tt>, <tt>update_attribute</tt> or <tt>update_attributes</tt>) will result in a SQL update operation. Active Record will use this facts to perform validations upon your objects, avoiding then to be recorded to the database if their inner state is invalid in some way. You can specify validations that will be beformed every time a object is saved, just when you're creating a new record or when you're updating an existing one.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<img src="./images/icons/caution.png" alt="Caution" />
+</td>
+<td class="content">There are four methods that when called will trigger validation: <tt>save</tt>, <tt>save!</tt>, <tt>update_attributes</tt> and <tt>update_attributes!</tt>. There is one method left, which is <tt>update_attribute</tt>. This method will update the value of an attribute without triggering any validation, so be careful when using <tt>update_attribute</tt>, since it can let you save your objects in an invalid state.</td>
+</tr></table>
+</div>
<h3 id="_the_meaning_of_em_valid_em">2.2. The meaning of <em>valid</em></h3>
<div class="para"><p>For verifying if an object is valid, Active Record uses the <tt>valid?</tt> method, which basically looks inside the object to see if it has any validation errors. These errors live in a collection that can be accessed through the <tt>errors</tt> instance method. The proccess is really simple: If the <tt>errors</tt> method returns an empty collection, the object is valid and can be saved. Each time a validation fails, an error message is added to the <tt>errors</tt> collection.</p></div>
</div>
@@ -722,7 +730,7 @@ http://www.gnu.org/software/src-highlite --> <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
</tt></pre></div></div>
-<div class="para"><p>If your validation rules are too complicated and you want to break it in small methods, you can implement all of them and call one of <tt>validate</tt>, <tt>validate_on_create</tt> or <tt>validate_on_update</tt> methods, passing it the symbols for the methods' names.</p></div>
+<div class="para"><p>If your validation rules are too complicated and you want to break them in small methods, you can implement all of them and call one of <tt>validate</tt>, <tt>validate_on_create</tt> or <tt>validate_on_update</tt> methods, passing it the symbols for the methods' names.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
|