Rails 8.1 ships ActiveSupport::EventReporter as a first-class global message bus, offering a clean alternative to callback-heavy models and scattered service objects. The post walks through a practical e-commerce example showing how to publish events with Rails.event.notify, write focused subscriber classes, wire them up in an initializer, and use tagged events to conditionally suppress side effects (e.g., skipping notifications during bulk imports). Trade-offs are addressed honestly: the pattern introduces indirection, is synchronous and in-process (not a replacement for Kafka), and changes how you write tests. A bonus section covers StructuredEventSubscriber as a bridge between ActiveSupport::Notifications and the new event pipeline.

10m read timeFrom rorvswild.com
Post cover image
Table of contents
An Observer With Rails Batteries # #“Tell, Don’t Ask” At Scale # #Trade-offs and Limitations # #Conclusion # #Bonus: StructuredEventSubscriber # #Julian Rubisch Guest author

Sort: