Search code examples
ruby-on-railsexceptionobserver-pattern

Guidance: how to handle exception handling involving tons of observers for an activty stream pattern?


I'm implementing an ActivityStream for my site based on the answer provided in this question: What's the best manner of implementing a social activity stream?.

My approach is to use observers after_create to create the activity record, including the metadata. I have a ton of observers, and don't want to write exception handling block for each one. Is there a way I can use some super observer class to handle the exceptions, with the observer subclasses calling a yield?


Solution

  • Not entirely sure if it applies, but i would create a module with all the shared code (i am guessing a lot of code is similar), and include that in each observer.