diff --git a/app/controllers/case_contacts/form_controller.rb b/app/controllers/case_contacts/form_controller.rb index 73cb68558c..bf95767fd3 100644 --- a/app/controllers/case_contacts/form_controller.rb +++ b/app/controllers/case_contacts/form_controller.rb @@ -3,13 +3,13 @@ class CaseContacts::FormController < ApplicationController before_action :set_progress before_action :require_organization! + before_action :set_case_contact, only: [:show, :update] after_action :verify_authorized steps(*CaseContact::FORM_STEPS) # wizard_path def show - @case_contact = CaseContact.find(params[:case_contact_id]) authorize @case_contact get_cases_and_contact_types @page = wizard_steps.index(step) + 1 @@ -20,7 +20,6 @@ def show end def update - @case_contact = CaseContact.find(params[:case_contact_id]) authorize @case_contact params[:case_contact][:status] = step.to_s if !@case_contact.active? && params.key?(:case_contact) remove_unwanted_contact_types @@ -49,6 +48,10 @@ def update private + def set_case_contact + @case_contact = CaseContact.find(params[:case_contact_id]) + end + def get_cases_and_contact_types @casa_cases = policy_scope(current_organization.casa_cases) @casa_cases = @casa_cases.where(id: @case_contact.casa_case_id) if @case_contact.active?