Different role based access for two pages with same model in activeadmin using cancan/pundit

441 Views Asked by At

I have a Payroll model using which I have to create two different pages in active admin, each with slight change in columns and logic.

ActiveAdmin.register Payroll do
end

ActiveAdmin.register Payroll, as: "Customised Payroll" do
end

In Cancan or Pundit, Giving access to Payroll(as policy name is bound to model name) causes both Payroll and Customised Payroll to be visible together. I want Payroll to be accessible to a set of roles and Customised Payroll to be accessible by a different set of roles.

I cant use the same page with conditional logic/scope for display. It has to be two pages. How do I give role based access differently for the two pages?

1

There are 1 best solutions below

0
On

You can create duplicate model for that:

class CustomisedPayroll < Payroll
end

and activeadmin's resource customised_payroll.rb After that you will be able to create ability for two resources