Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CanCan skip authorization for some action

I have problem with CanCan gem which I can't solve. In my controller I have action "confirm" which is a member route for "reservations" resource. I don't want to authorize resource by CanCan in this action so I do something like that in controller:

load_and_authorize_resource except: :confirm

But now I have error:

This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check.

How can I skip authorization for proper action in CanCan?

like image 745
Mateusz Urbański Avatar asked Jan 10 '23 08:01

Mateusz Urbański


1 Answers

I think something like this might work in your controller,

skip_authorization_check only: :confirm
load_and_authorize_resource except: :confirm

Hope this helps!

like image 119
strivedi183 Avatar answered Jan 18 '23 08:01

strivedi183