Indicate the reason for denial of access using CanCan

I really like the Rails authorization gem CanCan . However, I found that I have several conditions for certain privileges, and I would like to be able to send various error messages to the user, depending on why he or she was denied access.

Does CanCan have a mechanism for this behavior? I have problems finding. Should I fork out and add this behavior myself?

+3
source share
1 answer

I don’t think you can do it with CanCan right out of the box. It really makes it possible to say whether the user can or cannot do something.

, , , Ability . - Ability .

Ability, , , , - . , , .

, Ability current_ability, CanCan . , can? cannot? , , , , why?, , Ability .

, authorize!, .

, , - .

+2

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


All Articles