diff options
author | Jamison Dance <jergason@gmail.com> | 2010-08-26 21:20:22 -0600 |
---|---|---|
committer | Jamison Dance <jergason@gmail.com> | 2010-08-26 21:20:22 -0600 |
commit | 6398eba2400af004d9db19217f9d43ea7a33d877 (patch) | |
tree | f9f0755bbf42a2a86eff5a6b4d9bb46902745bee /railties/guides/source/active_record_validations_callbacks.textile | |
parent | 4d8158d9e5ada4aff5dc62712b7c4730b60cde48 (diff) | |
parent | 6eed7b36a2ec6f94d9ac3f254b05697649b78881 (diff) | |
download | rails-6398eba2400af004d9db19217f9d43ea7a33d877.tar.gz rails-6398eba2400af004d9db19217f9d43ea7a33d877.tar.bz2 rails-6398eba2400af004d9db19217f9d43ea7a33d877.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/guides/source/active_record_validations_callbacks.textile')
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 2601a8fbcf..a8ccfc7e40 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -57,7 +57,7 @@ We can see how it works by looking at some +rails console+ output: => false </shell> -Creating and saving a new record will send a SQL +INSERT+ operation to the database. Updating an existing record will send a SQL +UPDATE+ operation instead. Validations are typically run before these commands are sent to the database. If any validations fail, the object will be marked as invalid and Active Record will not perform the +INSERT+ or +UPDATE+ operation. This helps to avoid storing an invalid object in the database. You can choose to have specific validations run when an object is created, saved, or updated. +Creating and saving a new record will send an SQL +INSERT+ operation to the database. Updating an existing record will send an SQL +UPDATE+ operation instead. Validations are typically run before these commands are sent to the database. If any validations fail, the object will be marked as invalid and Active Record will not perform the +INSERT+ or +UPDATE+ operation. This helps to avoid storing an invalid object in the database. You can choose to have specific validations run when an object is created, saved, or updated. CAUTION: There are many ways to change the state of an object in the database. Some methods will trigger validations, but some will not. This means that it's possible to save an object in the database in an invalid state if you aren't careful. @@ -382,7 +382,7 @@ class Account < ActiveRecord::Base end </ruby> -The validation happens by performing a SQL query into the model's table, searching for an existing record with the same value in that attribute. +The validation happens by performing an SQL query into the model's table, searching for an existing record with the same value in that attribute. There is a +:scope+ option that you can use to specify other attributes that are used to limit the uniqueness check: |