Skip to content

DamageLabs/paper_trail_manager

Repository files navigation

PaperTrailManager

CI

Browse, view, and revert changes to records in Ruby on Rails applications using the paper_trail gem.

Requirements

Installation

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 install

Add 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.

Configuration

Create an initializer (e.g. config/initializers/paper_trail_manager.rb) to customize behavior.

Authorization

Control when reverts are allowed:

PaperTrailManager.allow_revert_when do |controller, version|
  controller.current_user&.admin?
end

Whodunnit

Configure how to look up users referenced in PaperTrail's whodunnit column:

PaperTrailManager.whodunnit_class = User
PaperTrailManager.whodunnit_name_method = :nicename  # defaults to :name

Item Names

Specify a method to identify items on the index page:

PaperTrailManager.item_name_method = :nicename

User Links

Customize (or disable) the user path helper:

PaperTrailManager.user_path_method = :admin_path  # defaults to :user_path
PaperTrailManager.user_path_method = nil           # no user link

Engine Integration

When embedding PaperTrailManager inside another Rails engine:

PaperTrailManager.base_controller = "MyEngine::ApplicationController"
PaperTrailManager.route_helpers = MyEngine::Engine.routes.url_helpers
PaperTrailManager.layout = 'my_engine/application'

Development

Setup:

git clone https://github.com/DamageLabs/paper_trail_manager.git
cd paper_trail_manager
bundle install

Running tests:

appraisal rake

The first run downloads gems for each Rails version in the test matrix, which may take a while.

Test Matrix

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.

Adding Support for New Versions

  1. Update the Appraisals file with new version combinations
  2. Run appraisal generate && appraisal install
  3. Fix any breaking changes
  4. Submit a pull request

License

MIT — see LICENSE.txt for details.

History

This project was originally developed by Igal Koshevoy. Igal passed away on April 9th, 2013, and Tony Guntharp took over maintenance of the project.

About

Browse, subscribe, view and revert changes to records when using Ruby on Rails 3 and the `paper_trail` gem.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors