Posted By

stuckinrealtime on 11/17/06


Tagged

rails activerecord


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

webstic
Priestd09


Make Observers For Your Own Methods


 / Published in: Ruby
 

Rails builds on the standard Ruby observer, so you can too.

Originally found at http://rails.techno-weenie.net/forums/1/topics/672?page=6, so don't give me any credit ;)

  1. def my_method!
  2. #- Your Method Code Here -#
  3. self.class.changed
  4. self.class.notify_observers(:my_method, self)
  5. end
  6.  
  7. That will call any observers 'my_method' method.

Report this snippet  

You need to login to post a comment.