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,
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
  7. That will call any observers 'my_method' method.

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.