问题描述
我正在努力实施CanCan。由于某些原因,当我尝试获取有关模型权限的详细信息时,CanCan会一直拒绝我的访问。而且我不知道为什么。
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.
有没有办法让CanCan具体化,也许是在日志中或有关为什么拒绝Access的开发中?
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.
这对调试很有帮助。
谢谢 p>
Thanks
推荐答案
您可以在ApplicationController中添加 rescue_from
块以处理CanCan异常并进行设置您的自定义错误消息在那里。有关详细说明,请参见。
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.
这篇关于CanCan-访问被拒绝-使CanCan在LOG中指定的方法为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!