aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2012-10-01 21:05:53 -0400
committerschneems <richard.schneeman@gmail.com>2012-10-02 11:31:24 -0400
commitc8f50ef02bcf5dc8b9d42e174581cae27a160821 (patch)
treeef4fbd3868cea51c13de3d99c1a0a5f5bd0f9c2e /guides
parente8bdbef00a26fd469c255cd5cfb4b3c71278beb4 (diff)
downloadrails-c8f50ef02bcf5dc8b9d42e174581cae27a160821.tar.gz
rails-c8f50ef02bcf5dc8b9d42e174581cae27a160821.tar.bz2
rails-c8f50ef02bcf5dc8b9d42e174581cae27a160821.zip
Add command before bash output
Add tip for command line.
Diffstat (limited to 'guides')
-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.