aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_validations_callbacks.md
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source/active_record_validations_callbacks.md')
-rw-r--r--guides/source/active_record_validations_callbacks.md3
1 files changed, 3 insertions, 0 deletions
diff --git a/guides/source/active_record_validations_callbacks.md b/guides/source/active_record_validations_callbacks.md
index f32c1050ce..333cbdd90b 100644
--- a/guides/source/active_record_validations_callbacks.md
+++ b/guides/source/active_record_validations_callbacks.md
@@ -50,6 +50,7 @@ end
We can see how it works by looking at some `rails console` output:
```ruby
+$ rails console
>> p = Person.new(:name => "John Doe")
=> #<Person id: nil, name: "John Doe", created_at: nil, updated_at: nil>
>> p.new_record?
@@ -60,6 +61,8 @@ We can see how it works by looking at some `rails console` output:
=> false
```
+TIP: All lines starting with a dollar sign `$` are intended to be run on the command line.
+
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.