Make Observers For Your Own Methods


/ Published in: Ruby
Save to your folder(s)

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 ;)


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.