简体   繁体   中英

Custom gem `active_admin` in Ruby On rails

Currently, I am working on a project using gem active_admin to act as site admin. Now I receive a request like this:

On the admin page, there will be a new user type super_admin , this user can create many companies, each company will have a manager (also created by super_admin ).

The manager of company A will login to the admin site (with the account created in step 1), you can only operate on the objects of company A, similar to company B, C, D...

I do not know how to implement this logic with gem active_admin, can you give me suggestions on how to do or keywords to handle logic like this with active_admin gem?

You could use ActiveAdmin's authorization adapter to achieve this.

By defining your own authorization adapter, you can have a check in your authorized? method to see if the subject (the record that's being accessed) belongs to the current_user 's company and only return true if the user has access. This way, you can also limit certain actions to be only available for the super admin.

AcitveAdmin then uses your authorization adapter to only show the related records to the admins and they can only edit or delete those records.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM