Ruby on Rails Q & A


What is the Rails event store?

Rails Event Store (often abbreviated as RES) is a library used to support event sourcing in Ruby on Rails applications. Event sourcing is an architectural pattern wherein changes to an application state are captured as a series of events, rather than merely updating the state in a database. These events are then stored in an event store, which acts as a log of changes over time.


Here’s a breakdown of the Rails Event Store:


  1. Event-Driven Architecture: RES promotes the event-driven architecture. This means that instead of directly modifying the state of the system, actions result in events being emitted. These events can then be handled by various parts of the application, fostering a decoupled system.


  1. Immutable Event Log: All events in RES are immutable. Once an event is stored, it cannot be changed. This ensures a reliable history of all changes, making it invaluable for debugging, audits, and even some business processes.


  1. Rich Tooling: RES comes with tools that allow developers to read and write to the event store, build and replay projections, and even integrate with external systems. This is crucial for systems that use CQRS (Command Query Responsibility Segregation) alongside event sourcing.


  1. Integrations and Extensions: Being a part of the Ruby ecosystem, RES can be extended with additional RubyGems and integrated with other tools and libraries in the Rails community. This allows for adding functionalities like event versioning, upcasting, or integration with messaging systems.


  1. Scalability and Flexibility: With RES, it’s possible to model complex domain logic using events, making the system more resilient and adaptable to changes. Furthermore, by separating the write and read operations (through CQRS), applications can achieve greater scalability.


Rails Event Store provides a robust foundation for building Rails applications that utilize event sourcing. By capturing every change as an event, developers gain greater flexibility, traceability, and potential for scalability. However, while powerful, it’s essential to understand the implications and challenges of event sourcing and CQRS before adopting them in a project.

Previously at
Flag Argentina
time icon
Senior Software Engineer with a focus on remote work. Proficient in Ruby on Rails. Expertise spans y6ears in Ruby on Rails development, contributing to B2C financial solutions and data engineering.