// the find
paper-trail-gem/paper_trail
Track changes to your rails models
PaperTrail is an ActiveRecord audit log gem that stores a snapshot of your model before each change, letting you revert records, page through their history, or restore destroyed ones. It's been around since Rails 2 days and is the de facto standard for this problem in Rails apps. If you need to know who changed what and when, this is what you reach for.
Stores pre-change state rather than post-change, which means you can start tracking existing records without losing the 'before' baseline — a subtle but important design choice. The `whodunnit` + `PaperTrail.request` thread-local scoping is well thought out for web apps: you set it once in a controller callback and it flows through without threading issues. Custom metadata columns let you denormalize audit-relevant data (author_id, IP, etc.) directly onto version rows, which saves you from deserializing every version just to filter them. The serializer abstraction and custom version class support mean you can adapt it to jsonb columns and per-table version tables without forking it.
The `versions` table balloons fast on high-write models — every update to a busy table is a full object snapshot, not a diff. There's a `version_limit` config but it's a blunt instrument and doesn't apply to create events. Association tracking was extracted into a separate gem (paper_trail-association_tracking) and described as having 'many issues'; if you need to reify a record and its associations together, you're on your own. The `item_id` polymorphism problem — deleted parent records can have their IDs reused by new records, corrupting the version linkage — is documented but the only practical solution given is soft-deletes, which is a significant architectural imposition on adopters.