Browse files

Remove API links and add TODOs #26

  • Loading branch information...
1 parent ed1f674 commit d39290cf0e582993bdfcd48f92544da174788c05 @lifo lifo committed Feb 4, 2009
Showing with 22 additions and 16 deletions.
  1. +22 −16 railties/guides/source/activerecord_validations_callbacks.textile
@@ -55,34 +55,40 @@ CAUTION: There are many ways to change the state of an object in the database. S
The following methods trigger validations and generally save the object to the database:
-* "create": (creates an object, but does not save to the database)
-* "create!":
-* "save":
-* "save!":
-* "update":
-* "update_attributes":
-* "update_attributes!":
+* +create+
+* +create!+
+* +save+
+* +save!+
+* +update+
+* +update_attributes+
+* +update_attributes!+
The following methods _do not_ trigger validations, but _do_ change the state of the object in the database. They should be used with caution:
-* "decrement!":
-* "decrement_counter":
-* "increment!":
-* "increment_counter":
-* "toggle":
-* "toggle!":
-* "update_all":
-* "update_attribute":
-* "update_counters":
+* +decrement!+
+* +decrement_counter+
+* +increment!+
+* +increment_counter+
+* +toggle+
+* +toggle!+
+* +update_all+
+* +update_attribute+
+* +update_counters+
Note that +save+ has the ability to bypass validations. This technique should be used with caution:
* "save(false)":
+h4. Skipping Validations
+TODO: Probably move the list above and mention save(false). Also mention that save(false) doesn't only skip the validations, but a lots of other callbacks too.
h4. Object#valid?
To verify whether an object is valid, Active Record uses the +valid?+ 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 +errors+ instance method. The process is really simple: If the +errors+ 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 +errors+ collection.
+h4. Object#invalid?
h3. Declarative Validation Helpers
Active Record offers many pre-defined validation helpers that you can use directly inside your class definitions. These helpers create validation rules that are commonly used. Every time a validation fails, an error message is added to the object's +errors+ collection, and this message is associated with the field being validated.

0 comments on commit d39290c

Please sign in to comment.