A Ruby gem for creating and restoring explicit snapshots of ActiveRecord models and their associations with a transparent, white-box design.
ActiveSnapshot is a Ruby gem that simplifies creating and restoring snapshots of ActiveRecord models and their associations. It solves the problem of versioning and restoring complex data structures by providing an explicit, white-box API that avoids automatic callbacks and ensures predictable behavior. Developers use it to capture model states, track associated records, and restore data with full control over the process.
Ruby on Rails developers who need to implement model versioning, data restoration, or audit trails for ActiveRecord models with associations. It's particularly suited for teams that prioritize understanding their versioning logic over automated, opaque solutions.
Developers choose ActiveSnapshot for its transparency and simplicity—its small API and readable source code allow full customization and understanding, unlike black-box alternatives. It provides explicit control over snapshot creation and restoration, avoiding hidden callbacks and ensuring data integrity.
Simplified snapshots and restoration for ActiveRecord models and associations with a transparent white-box implementation
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Snapshots are created only upon explicit request via create_snapshot!, avoiding automatic callbacks that can lead to unpredictable behavior, as emphasized in the README's philosophy.
The has_snapshot_children block allows custom tracking of nested associations and supports custom delete methods, enabling complex data restoration scenarios as shown in the examples.
Provides built-in diffing capabilities to compare changes between snapshots or against the current record, useful for audit trails and debugging, with a clear API demonstrated in the README.
Fetch snapshot data as readonly ActiveRecord instances using fetch_reified_items, allowing safe inspection of historical data without database writes, with options to override readonly for custom processing.
Dropping database columns can silently break restoration, requiring additional scripts to detect issues, as the README warns, adding overhead for schema migrations.
Tracking associations requires defining a custom block with manual eager loading and mapping, which can be error-prone and cumbersome for deeply nested models compared to declarative solutions.
Snapshots and snapshot items are never destroyed automatically, forcing manual lifecycle management that could lead to data bloat if overlooked, as stated in the key features.