Created
June 28, 2019 10:44
-
-
Save sideshowbandana/ecf06bb2249df00afe7b53a13acde6e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def current_ability | |
| @current_ability ||= Abilities::Factory.ability_for(self.class, current_user) | |
| end | |
| rescue_from CanCan::AccessDenied do |exception| | |
| respond_to do |format| | |
| format.jsonapi { render jsonapi: { meta: { error: exception.message } }, status: :forbidden } | |
| format.json { head :forbidden, content_type: 'text/html' } | |
| format.html { redirect_to main_app.root_url, notice: exception.message } | |
| format.js { head :forbidden, content_type: 'text/html' } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment