diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-07 00:33:26 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-07 00:33:26 -0500 |
commit | 9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d (patch) | |
tree | 08eecfe9108d1bad360c283ee730b61d7f13c85f | |
parent | 552f535796b92df57ae7e7ea339307c45683c71b (diff) | |
download | rails-9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d.tar.gz rails-9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d.tar.bz2 rails-9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d.zip |
adding observer example
-rw-r--r-- | activemodel/README.rdoc | 10 |
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 |