Permalink
Browse files

adding observer example

  • Loading branch information...
1 parent 552f535 commit 9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d Francesco Rodriguez committed May 7, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 activemodel/README.rdoc
View
@@ -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

0 comments on commit 9f3637f

Please sign in to comment.