Giter Club home page Giter Club logo

active_admin_role's Introduction

ActiveAdminRole

CAUTION: Sorry, this gem is not maintained now. I'm looking for maintainer has motivation for apps using ActiveAdmin. Please somebody help me. See more

Role based authorization with CanCanCan for Active Admin

Installation

Add this line to your application's Gemfile:

gem 'active_admin_role'

And run bundle

Dependencies

  • rails (>= 5.0.0)
  • activeadmin (>= 1.2.0)
  • cancancan (>= 1.15.0)

Sample application

https://github.com/activeadmin-plugins/active_admin_role_sample

Usage

  1. Run this command after rails generate active_admin:install:
$ bin/rails generate active_admin_role:install
  create  config/initializers/active_admin_role.rb
  insert  app/models/admin_user.rb
  create  db/migrate/20161128090641_add_role_to_admin_users.rb
  create  db/migrate/20161128090642_create_active_admin_managed_resources.rb
  create  db/migrate/20161128090643_create_active_admin_permissions.rb
  create  app/models/ability.rb
    gsub  config/initializers/active_admin.rb
  create  app/admin/permissions.rb
  insert  app/admin/admin_users.rb

$ bin/rails db:migrate
  1. You have to login as admin after migration.

  2. You have to Reload permissions.

  1. Edit permissions however you like.

  1. Of course, you can edit AdminUser's roles.

Configuration

ActiveAdminRole.configure do |config|
  # [Required:Hash]
  # == Role | default: { guest: 0, support: 1, staff: 2, manager: 3, admin: 99 }
  config.roles = { guest: 0, support: 1, staff: 2, manager: 3, admin: 99 }

  # [Optional:Array]
  # == Special roles which don't need to manage on database
  config.super_user_roles = [:admin]
  config.guest_user_roles = [:guest]

  # [Optional:String]
  # == User class name | default: 'AdminUser'
  config.user_class_name = "AdminUser"

  # [Optional:Symbol]
  # == Default permission | default: :cannot
  config.default_state = :cannot
end

License

MIT License

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.