Skip to content

Instantly share code, notes, and snippets.

@bramswenson
Last active August 29, 2015 14:15
Show Gist options
  • Save bramswenson/2b1c6953cb18c726a571 to your computer and use it in GitHub Desktop.
Save bramswenson/2b1c6953cb18c726a571 to your computer and use it in GitHub Desktop.
paper_trail exploration

Exploring paper_trail gem

  1. These notes are meant to follow reading the README. Please start there.
  2. Primary interface is the has_paper_trail class method added to ActiveRecord::Base.
  3. Calling this method adds some associations and callbacks to the model.
  4. These associations are to PaperTrail::Version models or its ancestors all which inherit ActiveRecord::Base. This ActiveModel::Concern module provides all the features.
  5. Versions can be in many tables and a model may have many version types 1, 2, 3
  6. Versions can store custom meta data but any data will require columns on the version table 1, 2
  7. Versions help to track who was responsible for a change via the whodunnit attribute 1, 2
  8. One can add whodunnit info with a custom controller helper but any info will require columns on the version table.
  9. Diffing requires storing changesets which requires the object_changes column in your versions table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment