aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/README.rdoc
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-07 00:33:26 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-07 00:33:26 -0500
commit9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d (patch)
tree08eecfe9108d1bad360c283ee730b61d7f13c85f /activemodel/README.rdoc
parent552f535796b92df57ae7e7ea339307c45683c71b (diff)
downloadrails-9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d.tar.gz
rails-9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d.tar.bz2
rails-9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d.zip
adding observer example
Diffstat (limited to 'activemodel/README.rdoc')
-rw-r--r--activemodel/README.rdoc10
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index 1fd75141f8..0c7089598c 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -135,6 +135,16 @@ behavior out of the box:
pattern in a Rails App and take advantage of all the standard observer
functions.
+ class PersonObserver < ActiveModel::Observer
+ def after_create(person)
+ person.logger.info("New person added!")
+ end
+
+ def after_destroy(person)
+ person.logger.warn("Person with an id of #{person.id} was destroyed!")
+ end
+ end
+
{Learn more}[link:classes/ActiveModel/Observer.html]
* Making objects serializable