How to enable ActiveAdmin resources using Pundit?

A CanCanhelper method load_and_authorize_resourcecould be called globally before_filter(in application_controller). This would ensure that all ActiveAdmin controller actions are also authorized.

But with Punditsuch an auxiliary method load_and_authorize_resourcedoes not exist. All Pundit documents and guides talk about the challenge authorizein every action. I am fine with authorization permission in every action. But in ActiveAdmin, actions are not displayed by default. Should I open every action in every controller and call authorizeand then call super?

This seems wrong. So, can someone tell me how to use Pundit to authorize actions in ActiveAdmin?

Update

I know about the Pundit authorization adapter. I am using the main branch of AA, and I configured AA to use the Pundit adapter, as described here here . My question is: how can I use an adapter? config.authorization_adapter = ActiveAdmin::PunditAdapterBy simply setting , does it automatically invoke authorization of each action in ActiveAdmin? I do not think so.

For example, in CanCan, even after installation config.authorization_adapter = ActiveAdmin::CanCanAdapter, you still need to set the load_and_authorize_resourcebefore_filter global file so that it automatically resolves all AA actions.

+4
source share
1 answer

ActiveAdmin Pundit. ActiveAdmin, Pundit . pundit_adapter.rb ActiveAdmin, .

. ActiveAdmin PR # 2857, , .


, ActiveAdmin Pundit, : , , , , , , . .

, Pundit , ActiveAdmin. template, . ActiveAdmin .

+2

Source: https://habr.com/ru/post/1539461/


All Articles