From dbaded000f352dac565badd4683d383b9a862711 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Fri, 11 Sep 2015 14:32:24 +0200 Subject: [PATCH] return forbidden for forbidden json requests --- app/controllers/application_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0b697fd..fa00f9f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,7 +4,10 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception rescue_from CanCan::AccessDenied do |exception| - redirect_to root_url, alert: exception.message + respond_to do |format| + format.json { render nothing: true, status: :forbidden } + format.html { redirect_to root_url, alert: exception.message } + end end def authenticate_user_or_client!