Jeff Dean's blog
I'm currently working on a large app where certain things have to happen when records are created, updated and deleted, such as:
- Publishing to an activity feed
- Generating emails
- Adding entries to a changelog
- Generating tasks and reminders
Further, the requirements state that admin users should be able to configure which of these actions happen for which objects in the system, who they go to, what the text is etc...
At first this looks like a great place for ActiveRecord Observers. However, after working with Observers there are a few things I dislike - namely that you can't easily apply observers to all of your models, and you can't selectively turn them on and off in tests. To remedy that problem, I created ActiveModelListener.
ActiveModelListener is a simple, global ActiveRecord event listener framework, using a middleware-esque architecture that can easily be turned on and off.







