diff options
author | eparreno <emili@eparreno.com> | 2010-06-02 21:43:37 +0200 |
---|---|---|
committer | eparreno <emili@eparreno.com> | 2010-06-02 21:43:37 +0200 |
commit | 344a695383a211600d1dba16a5999bb68df92162 (patch) | |
tree | e859a7323419112fb33c706e3e9ea0853c0185a6 /railties/guides/source/activerecord_validations_callbacks.textile | |
parent | 785caba8666cb15df0bfb0187b857b0131ccdd5e (diff) | |
download | rails-344a695383a211600d1dba16a5999bb68df92162.tar.gz rails-344a695383a211600d1dba16a5999bb68df92162.tar.bz2 rails-344a695383a211600d1dba16a5999bb68df92162.zip |
AR validations: update sections 2.4 and 17.1
Diffstat (limited to 'railties/guides/source/activerecord_validations_callbacks.textile')
-rw-r--r-- | railties/guides/source/activerecord_validations_callbacks.textile | 10 |
1 files changed, 7 insertions, 3 deletions
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 => #<Person id: nil, name: nil> >> p.errors -=> #<ActiveRecord::Errors..., @errors={}> +=> {} >> p.valid? => false >> p.errors -=> #<ActiveRecord::Errors..., @errors={"name"=>["can't be blank"]}> +=> {:name=>["can't be blank"]} >> p = Person.create => #<Person id: nil, name: nil> >> p.errors -=> #<ActiveRecord::Errors..., @errors={"name"=>["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. +<shell> +rails generate observer User +</shell> + <ruby> class UserObserver < ActiveRecord::Observer def after_create(model) |