How to check cancan permission on user’s ActiveAdmin page?

I have the following Ability:

can :manage, ActiveAdmin::Page, name: 'My Page'

And it works fine, but I want to check if the user has the ability to manage this ActiveAdmin::Pageon different pages. Therefore, when I used the following:

can? :manage, ActiveAdmin::Page, name: 'My Page'

He returned truefor any page, even if it does not exist!

+4
source share
2 answers

Finally, I figured out the way, it looks weird because it uses register_page, but it works:

can? :manage, (ActiveAdmin::register_page 'My Page')
0
source

The code

can? :manage, ActiveAdmin::Page, name: 'My Page'

, ActiveAdmin::Page, name My Page. , , true.

, (, , ), : " ?" " " "?". , .

CanCan, , :

can? :manage, my_specific_page

my_specific_page ActiveAdmin::Page.

+8

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


All Articles