Track changes to your Rails models for auditing, versioning, and reverting to previous states.
PaperTrail is a Ruby gem that provides versioning and auditing for ActiveRecord models in Rails applications. It automatically tracks changes to models on create, update, and destroy events, allowing developers to view historical states, revert to previous versions, or restore deleted records. It solves the problem of maintaining a complete audit trail and version history for data changes in Rails applications.
Rails developers who need to implement auditing, versioning, or undo functionality for their ActiveRecord models, particularly in applications with compliance, regulatory, or data integrity requirements.
Developers choose PaperTrail for its simplicity, robustness, and self-contained version snapshots that store the pre-change state of models, ensuring versions remain independent. It offers extensive customization, including tracking specific attributes, storing metadata, and supporting flexible serialization, making it a comprehensive solution for ActiveRecord versioning.
Track changes to your rails models
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Stores pre-change states as self-contained YAML or JSON objects, ensuring versions are independent and reliable for auditing, as highlighted in the philosophy section.
Allows fine-grained control over versioning with options like :ignore, :only, and :skip to track specific attributes or events, and metadata support for additional context.
Easily tracks who made changes via whodunnit and custom metadata like IP addresses, enhancing audit trails with controller callbacks and model configurations.
Supports YAML (default) and JSON serialization, with optimization for PostgreSQL json/jsonb columns to improve query performance and storage efficiency.
Critical association versioning is now a separate, experimental gem (paper_trail-association_tracking), adding complexity and maintenance overhead as noted in section 4.b.
Storing full object snapshots instead of diffs can lead to rapidly growing versions tables, requiring manual cleanup and potentially impacting performance on large datasets.
Only works with ActiveRecord in Rails applications, making it unsuitable for projects using other ORMs or non-Rails frameworks, limiting its ecosystem.
While it tracks changes for adjacent versions via object_changes, diffing non-adjacent versions requires custom code or external libraries, as admitted in section 3.c.