Browse, view, and revert changes to records in Ruby on Rails applications using the paper_trail gem.
- Ruby >= 3.1
- Rails >= 6.1, < 8.0
- PaperTrail >= 12.0
- A pagination library: will_paginate or Kaminari
Add to your Gemfile:
gem 'paper_trail_manager'If you don't already use a pagination library, add one:
gem 'kaminari'
# or
gem 'will_paginate'Install:
bundle installAdd the route to config/routes.rb:
resources :changes, controller: 'paper_trail_manager/changes'Restart your server and visit /changes to browse, view, and revert your changes.
Create an initializer (e.g. config/initializers/paper_trail_manager.rb) to customize behavior.
Control when reverts are allowed:
PaperTrailManager.allow_revert_when do |controller, version|
controller.current_user&.admin?
endConfigure how to look up users referenced in PaperTrail's whodunnit column:
PaperTrailManager.whodunnit_class = User
PaperTrailManager.whodunnit_name_method = :nicename # defaults to :nameSpecify a method to identify items on the index page:
PaperTrailManager.item_name_method = :nicenameCustomize (or disable) the user path helper:
PaperTrailManager.user_path_method = :admin_path # defaults to :user_path
PaperTrailManager.user_path_method = nil # no user linkWhen embedding PaperTrailManager inside another Rails engine:
PaperTrailManager.base_controller = "MyEngine::ApplicationController"
PaperTrailManager.route_helpers = MyEngine::Engine.routes.url_helpers
PaperTrailManager.layout = 'my_engine/application'Setup:
git clone https://github.com/DamageLabs/paper_trail_manager.git
cd paper_trail_manager
bundle installRunning tests:
appraisal rakeThe first run downloads gems for each Rails version in the test matrix, which may take a while.
Tests run against multiple combinations via Appraisal:
| Rails | PaperTrail | Pagination |
|---|---|---|
| 6.1 | 12.0 | kaminari, will_paginate |
| 7.0 | 12.0 | kaminari, will_paginate |
| 7.0 | 15.0 | kaminari, will_paginate |
| 7.1 | 15.0 | kaminari, will_paginate |
CI runs each combination across Ruby 3.1, 3.2, and 3.3.
- Update the
Appraisalsfile with new version combinations - Run
appraisal generate && appraisal install - Fix any breaking changes
- Submit a pull request
MIT — see LICENSE.txt for details.
This project was originally developed by Igal Koshevoy. Igal passed away on April 9th, 2013, and Tony Guntharp took over maintenance of the project.