Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CanCan - Access denied - Way to make CanCan Specify in the LOG Why?

I'm working to implement CanCan. For some reason CanCan keeps giving me Access Denied when I try to get specific about model permissions. And I can't figure out why.

Is there a way to get CanCan to be specific, perhaps in the logs or in development about Why Access is denied? something like, No Read Ability to XXX Model.

That would be helpful for debugging.

Thanks

like image 755
AnApprentice Avatar asked Nov 03 '10 16:11

AnApprentice


2 Answers

You can add a rescue_from block in ApplicationController to handle CanCan exceptions and set your custom error message there. See the CanCan docs for a detailed explanation.

like image 151
zetetic Avatar answered Nov 17 '22 10:11

zetetic


You can add some output in your Ability model and check after what can or cannot your ability failed.

Or you can add a debugger session in start of you ability class.

like image 1
shingara Avatar answered Nov 17 '22 10:11

shingara