Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch action of admin user view not displaying assign as staff and other default roles in Rails 7. #26

Open
harisbilal1 opened this issue Jan 5, 2023 · 0 comments

Comments

@harisbilal1
Copy link

harisbilal1 commented Jan 5, 2023

Steps to reproduce

  1. I have follow the active_admin_role documentation and add (gem 'active_admin_role').
  2. Run this command (rails generate active_admin:install).
  3. then rake db:migrate
  4. after running migration i got permissions tab in my admin dashboard.
  5. Click Reload button in permissions tab and its create all permissions for me.
  6. Go back to the Admin user Index page and select a admin user in the listing and then click on batch action.
  7. Batch action drop-down only shows delete selected option and i'm expecting assign a staff selected and other options according to the existing roles.

active_admin

ActiveAdmin version: activeadmin (>= 1.2.0)

ActiveAdminRole version: active_admin_role (0.2.2)

Rails version: 7.0.4

Ruby version: 3.1.0

config/initializers/active_admin_role.rb :-

ActiveAdminRole.configure do |config|

config.roles = { guest: 0, support: 1, staff: 2, manager: 3, admin: 99 }

config.super_user_roles = [:admin]
config.guest_user_roles = [:guest]

config.user_class_name = "AdminUser"

config.default_state = :cannot
end

config/initializers/active_admin.rb :-

ActiveAdmin.setup do |config|

config.site_title = 'Project'

config.site_title_image = 'logo.png'

meta_tags_options = { viewport: 'width=device-width, initial-scale=1' }
config.meta_tags = meta_tags_options
config.meta_tags_for_logged_out_pages = meta_tags_options

config.authentication_method = :authenticate_admin_user!

CanCanAdapter or make your own. Please refer to documentation.

config.authorization_adapter = ActiveAdmin::CanCanAdapter

You can customize your CanCan Ability class name here.

config.cancan_ability_class = "Ability"

config.current_user_method = :current_admin_user

Default:

config.logout_link_path = :destroy_admin_user_session_path

config.comments = false

config.batch_actions = true

config.filter_attributes = %i[encrypted_password password password_confirmation]

config.localize_format = :long

ability.rb

class Ability
include CanCan::Ability
include ActiveAdminRole::CanCan::Ability

def initialize(user)
user ||= AdminUser.new

if user.super_user?
  can :manage, :all
else
  register_role_based_abilities(user)
end

# NOTE: Everyone can read the page of Permission Deny
can :read, ActiveAdmin::Page, name: 'Dashboard'

end
end

@harisbilal1 harisbilal1 changed the title Batch action of admin user view not displaying assign as staff and other default roles. Batch action of admin user view not displaying assign as staff and other default roles in Rails 7. Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant