diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ecd057d14..719c8abc4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,7 +17,10 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception rescue_from CanCan::AccessDenied do |exception| - redirect_to main_app.root_url, alert: exception.message + respond_to do |format| + format.html { redirect_to main_app.root_url, alert: exception.message } + format.json { render json: {error: exception.message}, status: :forbidden } + end end layout :set_layout