Belibaste / active_admin_versioning

Good for auditing or versioning for Active Admin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActiveAdminVersioning

Good for auditing or versioning for Active Admin (using PaperTrail)

Installation

Add this line to your application's Gemfile:

gem 'active_admin_versioning'

And then execute:

$ bundle

Configuration

In some cases you may need to display some extra or formatted text in whodunnit. For example whodunit is an ID of your user. And you want to display not just a number, but his E-mail.

Create configuration 'config/initializers/active_admin_versionings.rb'

ActiveAdminVersioning.configure do |config|
  config.whodunnit_attribute_name = :display_whodunnit
end

In you model:

has_paper_trail class_name: 'MyPaperTrail'
class MyPaperTrail < PaperTrail::Version
  def display_whodunnit
    AdminUser.find(whodunnit).email
  end
end

This alternative "whodunnit" will only be visible in "Version" sidebar and "Version" page.

Recipe for Rails 5

  1. Add necessary gems to Gemfile and bundle:
gem 'activeadmin', github: 'activeadmin'
gem 'devise'
gem 'inherited_resources', github: 'activeadmin/inherited_resources'
gem 'paper_trail', '~> 5.2.0'
gem 'active_admin_versioning'
  1. Install Active Admin and Paper Trail:
$ bin/rails generate active_admin:install
$ bin/rails generate paper_trail:install
$ bin/rails db:create db:migrate db:seed
  1. Add module of Paper Trail to AdminUser:
class AdminUser < ApplicationRecord
  has_paper_trail
end
  1. Run server bin/rails server and open localhost:3000

License

MIT License

About

Good for auditing or versioning for Active Admin

License:MIT License


Languages

Language:Ruby 96.3%Language:HTML 3.0%Language:Shell 0.7%