Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jemcode/rails_admin_history_rollback
History rollback for rails_admin with paper_trail
https://github.com/jemcode/rails_admin_history_rollback
history-rollback jemcode papertrail rails rails-admin ruby
Last synced: 18 days ago
JSON representation
History rollback for rails_admin with paper_trail
- Host: GitHub
- URL: https://github.com/jemcode/rails_admin_history_rollback
- Owner: jemcode
- License: mit
- Created: 2015-03-05T21:25:46.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2023-12-20T10:33:33.000Z (11 months ago)
- Last Synced: 2024-10-22T22:39:14.706Z (25 days ago)
- Topics: history-rollback, jemcode, papertrail, rails, rails-admin, ruby
- Language: Haml
- Homepage: https://rubygems.org/gems/rails_admin_history_rollback
- Size: 242 KB
- Stars: 41
- Watchers: 6
- Forks: 27
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: MIT-LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Rails Admin History Rollback
[![Gem Version](https://badge.fury.io/rb/rails_admin_history_rollback.svg)](http://badge.fury.io/rb/rails_admin_history_rollback)
[![Code Climate](https://codeclimate.com/github/rikkipitt/rails_admin_history_rollback/badges/gpa.svg)](https://codeclimate.com/github/rikkipitt/rails_admin_history_rollback)[RailsAdmin](https://github.com/sferik/rails_admin) extension for enabling users to easily visualise and revert their history audit created by the [PaperTrail](https://github.com/airblade/paper_trail) gem.
## Installation
To enable **rails_admin_history_rollback**, add the following to your `Gemfile` ensuring it is added *after* rails_admin:
```ruby
gem 'rails_admin'
gem 'rails_admin_history_rollback'
```It should go without saying that this plugin also requires the paper_trail gem.
E.g. `gem 'paper_trail'`
## Configuration
Simply enable paper_trail on your model `--with-changes --with-associations` and set up as usual by following the [paper_trail](https://github.com/airblade/paper_trail) instructions.```bash
rails generate paper_trail:install --with-changes --with-associations
```In the `rails_admin.rb` initializer, uncomment the following lines to enable auditing:
```ruby
history_index
history_show
```## Notes
You may also need to `require "paper_trail"` in `application.rb`
As pointed out in issue [#8](https://github.com/rikkipitt/rails_admin_history_rollback/issues/8), `paper_trail` master branch and release [v5.0.0](https://github.com/airblade/paper_trail/blob/master/CHANGELOG.md#500-unreleased) (when available) causes session issues. Login is reset by devise; `paper_trail` tries to access to the `current_user` variable before `devise` ([airblade/paper_trail#556](https://github.com/airblade/paper_trail#556)).
The fix is to manually add `set_paper_trail_whodunnit` before_action as advised here: (https://github.com/airblade/paper_trail#finding-out-who-was-responsible-for-a-change)
```ruby
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
[...]
before_action :set_paper_trail_whodunnit
[...]
end
```## Screenshots
![History view](https://github.com/rikkipitt/rails_admin_history_rollback/raw/main/screenshots/history.png "history view")
![Modal view](https://github.com/rikkipitt/rails_admin_history_rollback/raw/main/screenshots/modal.png "modal view")
## About Jemcode
[][hire]
This repository is maintained and funded by Jemcode Limited. We are [available for hire][hire].
[hire]: https://www.jemco.de?utm_source=github