From c8f50ef02bcf5dc8b9d42e174581cae27a160821 Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 1 Oct 2012 21:05:53 -0400 Subject: Add command before bash output Add tip for command line. --- guides/source/active_record_validations_callbacks.md | 3 +++ 1 file changed, 3 insertions(+) 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") => # >> 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. -- cgit v1.2.3