From a5e925c1d35ff10a22a98841f6a02925d4263947 Mon Sep 17 00:00:00 2001
From: Bogdan Gusiev <agresso@gmail.com>
Date: Wed, 24 Aug 2011 10:25:29 +0300
Subject: Add strict validation example to guides

---
 railties/guides/source/active_model_basics.textile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'railties/guides/source/active_model_basics.textile')

diff --git a/railties/guides/source/active_model_basics.textile b/railties/guides/source/active_model_basics.textile
index f3a2b2edbc..7d435456bd 100644
--- a/railties/guides/source/active_model_basics.textile
+++ b/railties/guides/source/active_model_basics.textile
@@ -184,20 +184,23 @@ Validations module adds the ability to class objects to validate them in Active
 class Person
   include ActiveModel::Validations
 
-  attr_accessor :name, :email
+  attr_accessor :name, :email, :token
   
   validates :name, :presence => true
   validates_format_of :email, :with => /^([^\s]+)((?:[-a-z0-9]\.)[a-z]{2,})$/i  
+  validates! :token, :presence => true
   
 end
 
-person = Person.new
+person = Person.new(:token => "2b1f325")
 person.valid?                        #=> false
 person.name  = 'vishnu'
 person.email  = 'me'
 person.valid?                        #=> false
 person.email = 'me@vishnuatrai.com'
 person.valid?                        #=> true
+person.token = nil
+person.valid?                        #=> raises ActiveModel::StrictValidationFailed
 </ruby>
 
 h3. Changelog
-- 
cgit v1.2.3

