From 344a695383a211600d1dba16a5999bb68df92162 Mon Sep 17 00:00:00 2001 From: eparreno Date: Wed, 2 Jun 2010 21:43:37 +0200 Subject: AR validations: update sections 2.4 and 17.1 --- .../guides/source/activerecord_validations_callbacks.textile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/activerecord_validations_callbacks.textile b/railties/guides/source/activerecord_validations_callbacks.textile index d83ea57864..1f9bc1279a 100644 --- a/railties/guides/source/activerecord_validations_callbacks.textile +++ b/railties/guides/source/activerecord_validations_callbacks.textile @@ -115,17 +115,17 @@ end >> p = Person.new => # >> p.errors -=> # +=> {} >> p.valid? => false >> p.errors -=> #["can't be blank"]}> +=> {:name=>["can't be blank"]} >> p = Person.create => # >> p.errors -=> #["can't be blank"]}> +=> {:name=>["can't be blank"]} >> p.save => false @@ -1112,6 +1112,10 @@ h4. Creating Observers For example, imagine a +User+ model where we want to send an email every time a new user is created. Because sending emails is not directly related to our model's purpose, we could create an observer to contain this functionality. + +rails generate observer User + + class UserObserver < ActiveRecord::Observer def after_create(model) -- cgit v1.2.3