Search code examples
ruby-on-railsruby-on-rails-3cancan

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


Solution

  • 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.