From 262664bd15c84f4223f0a4ce0e079f8c5f08bd3f Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Tue, 12 Oct 2021 17:20:16 +0100 Subject: [PATCH] Skip authenticity check only if it's a post#create json format request --- app/controllers/case_logs_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index a15811dac..36c32d286 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -1,5 +1,5 @@ class CaseLogsController < ApplicationController - skip_before_action :verify_authenticity_token + skip_before_action :verify_authenticity_token, only: [:create], if: :json_request? def index @submitted_case_logs = CaseLog.where(status: 1) @@ -72,6 +72,10 @@ private end end + def json_request? + request.format.json? + end + def create_params return {} unless params[:case_log]