diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index cd99837e6..2a0c6b84a 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -1,9 +1,6 @@ class CaseLogsController < ApplicationController skip_before_action :verify_authenticity_token, if: :json_api_request? before_action :authenticate, if: :json_api_request? - # rubocop:disable Style/ClassVars - @@form_handler = FormHandler.instance - # rubocop:enable Style/ClassVars def index @completed_case_logs = CaseLog.where(status: 2) @@ -42,13 +39,13 @@ class CaseLogsController < ApplicationController end def edit - @form = @@form_handler.get_form("2021_2022") + @form = FormHandler.instance.get_form("2021_2022") @case_log = CaseLog.find(params[:id]) render :edit end def submit_form - form = @@form_handler.get_form("2021_2022") + form = FormHandler.instance.get_form("2021_2022") @case_log = CaseLog.find(params[:id]) previous_page = params[:case_log][:previous_page] questions_for_page = form.questions_for_page(previous_page) @@ -76,14 +73,14 @@ class CaseLogsController < ApplicationController end def check_answers - form = @@form_handler.get_form("2021_2022") + form = FormHandler.instance.get_form("2021_2022") @case_log = CaseLog.find(params[:case_log_id]) current_url = request.env["PATH_INFO"] subsection = current_url.split("/")[-2] render "form/check_answers", locals: { subsection: subsection, form: form } end - form = @@form_handler.get_form("2021_2022") + form = FormHandler.instance.get_form("2021_2022") form.all_pages.map do |page_key, page_info| define_method(page_key) do |_errors = {}| @case_log = CaseLog.find(params[:case_log_id]) diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 26cd34b0d..c86d10adb 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -25,9 +25,7 @@ module CheckAnswersHelper def condition_not_met(case_log, question_key, question, condition) case question["type"] when "numeric" - # rubocop:disable Security/Eval - case_log[question_key].blank? || !eval(case_log[question_key].to_s + condition) - # rubocop:enable Security/Eval + case_log[question_key].blank? || !case_log[question_key].send(condition[0].to_sym, condition[1].to_i) when "radio" case_log[question_key].blank? || !condition.include?(case_log[question_key]) else