Giter Site home page Giter Site logo

lookprintufc / active_admin_versioning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moneytrackio/active_admin_versioning

0.0 0.0 0.0 39 KB

Good for auditing or versioning for Active Admin

License: MIT License

Shell 0.59% Ruby 96.76% HTML 2.65%

active_admin_versioning's Introduction

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
  config.display_version_diff = false # default false
  config.display_version_link = true # default true
end
  • When display_version_link is true, it s activate active admin Versions pages
  • When display_version_diff is true, it s add a panel to show pages to see all version diff

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

Run Spec

install gem:

bundle install 

setup spec:

RAILS_ENV=test bundle exec rake setup

run spec:

bundle exec rspec

License

MIT License

active_admin_versioning's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.