# paper-trail-gem/paper_trail

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/paper-trail-gem-paper-trail).**

7,022 stars · 910 forks · Ruby · MIT

## Links

- GitHub: https://github.com/paper-trail-gem/paper_trail
- awesome-repositories: https://awesome-repositories.com/repository/paper-trail-gem-paper-trail.md

## Topics

`activerecord` `audit` `log` `rails` `ruby`

## Description

PaperTrail is a Ruby on Rails versioning library and database audit trail system. It tracks changes to database models by capturing historical snapshots of object states and associating every modification with the specific user or process responsible for the update.

The project provides a model state reification tool to reconstruct model instances as they existed at a specific point in time and a data recovery framework to restore deleted database records by reifying their last known version.

The system covers a broad range of capabilities including version history navigation, changeset-based diffing, and the attachment of custom metadata such as IP addresses or user agents to version records. It also supports attribute-level filtering to control which fields trigger new versions and provides mechanisms for managing version history retention.

## Tags

### Data & Databases

- [Record State Versioning](https://awesome-repositories.com/f/data-databases/database-versioning/record-state-versioning.md) — Implements record-level value versioning to allow developers to compare differences and revert to previous data states. ([source](https://github.com/paper-trail-gem/paper_trail#readme))
- [Audit User Attribution](https://awesome-repositories.com/f/data-databases/audit-user-attribution.md) — Links database modifications to specific user identities or processes to maintain a comprehensive accountability trail. ([source](https://github.com/paper-trail-gem/paper_trail/blob/v3.0.9/README.md))
- [Data Recovery](https://awesome-repositories.com/f/data-databases/data-recovery.md) — Provides a framework for restoring records previously marked as deleted by reifying their last version.
- [Database Change Tracking](https://awesome-repositories.com/f/data-databases/database-change-tracking.md) — Provides a system for recording before-and-after attribute values of database models during lifecycle events. ([source](https://github.com/paper-trail-gem/paper_trail#readme))
- [Model State Reification](https://awesome-repositories.com/f/data-databases/model-state-reification.md) — Reconstructs a model instance as it existed at a specific point in time or before a particular change. ([source](https://github.com/paper-trail-gem/paper_trail/blob/master/README.md))
- [Object State Reification](https://awesome-repositories.com/f/data-databases/object-state-reification.md) — Provides a utility for reconstructing a Ruby on Rails model instance exactly as it existed at a specific point in time.
- [Serialized State Snapshots](https://awesome-repositories.com/f/data-databases/serialized-state-snapshots.md) — Persists full object states as serialized JSON or YAML strings in a dedicated versions table.
- [Record Recovery](https://awesome-repositories.com/f/data-databases/soft-deletion-mechanisms/record-recovery.md) — Allows for the reconstruction and reinstatement of deleted database records by reifying their last known version. ([source](https://github.com/paper-trail-gem/paper_trail/blob/v16.0.0/README.md))
- [State Attribute Filters](https://awesome-repositories.com/f/data-databases/attribute-filtering/state-attribute-filters.md) — Provides mechanisms to exclude specific attributes from being versioned to optimize storage.
- [Audit Change Metadata](https://awesome-repositories.com/f/data-databases/audit-change-metadata.md) — Records additional context for modifications, such as the specific command executed or source location. ([source](https://github.com/paper-trail-gem/paper_trail/wiki/Setting-whodunnit-in-the-rails-console))
- [Historical Data Querying Interfaces](https://awesome-repositories.com/f/data-databases/data-access-querying/historical-data-querying-interfaces.md) — Provides query interfaces to search through past table states and change logs based on attribute values.
- [Polymorphic Associations](https://awesome-repositories.com/f/data-databases/polymorphic-associations.md) — Uses polymorphic associations to link a single versions table to multiple different model types.
- [Associated Record Auditing](https://awesome-repositories.com/f/data-databases/relational-data-modeling/entity-associations/associated-record-auditing.md) — Tracks changes to associated models to maintain a complete audit trail of related data. ([source](https://github.com/paper-trail-gem/paper_trail/blob/master/CHANGELOG.md))
- [Version Audit Metadata](https://awesome-repositories.com/f/data-databases/version-audit-metadata.md) — Attaches arbitrary model or request data, such as IP addresses or user agents, to version records. ([source](https://github.com/paper-trail-gem/paper_trail/blob/v8.1.2/README.md))
- [Versioned Storage](https://awesome-repositories.com/f/data-databases/versioned-storage.md) — Maintains historical snapshots of database records as serialized JSON to allow for auditing and time-travel. ([source](https://github.com/paper-trail-gem/paper_trail/blob/master/lib/paper_trail/serializers/json.rb))

### Development Tools & Productivity

- [Database Audit Trails](https://awesome-repositories.com/f/development-tools-productivity/change-tracking/database-audit-trails.md) — Implements a database-specific audit trail that documents every modification with before-and-after values.
- [Change Data Capture](https://awesome-repositories.com/f/development-tools-productivity/change-tracking/row-level-change-logs/change-data-capture.md) — Captures row-level snapshots of model states during create, update, and delete events. ([source](https://github.com/paper-trail-gem/paper_trail/blob/master/CHANGELOG.md))

### Software Engineering & Architecture

- [Historical State Hydration](https://awesome-repositories.com/f/software-engineering-architecture/custom-object-hydration/historical-state-hydration.md) — Reconstructs model instances as they existed at specific points in time using historical snapshots.
- [Model](https://awesome-repositories.com/f/software-engineering-architecture/event-driven-callbacks/lifecycle-callbacks/model.md) — Implements automatic state capture by hooking into ActiveRecord model lifecycle events.
- [State Change Attribution](https://awesome-repositories.com/f/software-engineering-architecture/state-change-attribution.md) — Links every database modification to the specific user or process responsible for the change. ([source](https://github.com/paper-trail-gem/paper_trail/wiki/Setting-whodunnit-in-the-rails-console))
- [Attribute Changeset Differencing](https://awesome-repositories.com/f/software-engineering-architecture/attribute-changeset-differencing.md) — Calculates and stores precise attribute differences between adjacent versions for audit analysis.
- [Record Version Querying](https://awesome-repositories.com/f/software-engineering-architecture/specification-versioning/version-retrieval-utilities/version-history-managers/model-version-histories/record-version-querying.md) — Allows searching for historical records based on the values of the object or specific modifications made over time. ([source](https://github.com/paper-trail-gem/paper_trail#readme))
- [Version Retention Policies](https://awesome-repositories.com/f/software-engineering-architecture/specification-versioning/version-retrieval-utilities/version-history-managers/version-retention-policies.md) — Implements limits on the number of stored versions or deletes old records based on timestamps to prevent database bloat. ([source](https://github.com/paper-trail-gem/paper_trail/blob/v3.0.9/README.md))
- [State Version Diffing](https://awesome-repositories.com/f/software-engineering-architecture/state-version-diffing.md) — Retrieves a changeset of differences between adjacent versions to identify modified attributes. ([source](https://github.com/paper-trail-gem/paper_trail/blob/v3.0.9/README.md))
- [Object Timeline Navigation](https://awesome-repositories.com/f/software-engineering-architecture/version-history-viewers/document-versioning/version-history-browsers/object-timeline-navigation.md) — Enables sequential movement through an object's modification history using previous and next version pointers. ([source](https://github.com/paper-trail-gem/paper_trail/blob/master/README.md))

### Web Development

- [Rails Audit Libraries](https://awesome-repositories.com/f/web-development/rails-audit-libraries.md) — Provides comprehensive audit logging and change tracking specifically designed for Ruby on Rails ActiveRecord models.
- [Request-Scoped State](https://awesome-repositories.com/f/web-development/global-state-access/request-scoped-state.md) — Uses request-scoped state to attribute database changes to the specific user making the request.

### Security & Cryptography

- [Entity Audit Logs](https://awesome-repositories.com/f/security-cryptography/compliance-and-audit-tools/entity-audit-logs.md) — Records historical changes to database entities and associated request metadata for compliance and debugging.
