diff --git a/app/controllers/case_contacts/form_controller.rb b/app/controllers/case_contacts/form_controller.rb index fe50128d8d..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,14 +20,8 @@ def show end def update - @case_contact = CaseContact.find(params[:case_contact_id]) authorize @case_contact - if @case_contact.active? - # do nothing - else - params[:case_contact][:status] = step.to_s - end - + params[:case_contact][:status] = step.to_s if !@case_contact.active? && params.key?(:case_contact) remove_unwanted_contact_types remove_nil_draft_ids if @case_contact.update(case_contact_params) @@ -54,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? diff --git a/app/values/case_contact_parameters.rb b/app/values/case_contact_parameters.rb index 5e1339cfd6..ebaf8f0aae 100644 --- a/app/values/case_contact_parameters.rb +++ b/app/values/case_contact_parameters.rb @@ -2,7 +2,7 @@ class CaseContactParameters < SimpleDelegator def initialize(params) new_params = - params.require(:case_contact).permit( + params.fetch(:case_contact, {}).permit( :duration_minutes, :occurred_at, :contact_made, diff --git a/app/views/case_contacts/form/expenses.html.erb b/app/views/case_contacts/form/expenses.html.erb index b9c8613525..0b780d973c 100644 --- a/app/views/case_contacts/form/expenses.html.erb +++ b/app/views/case_contacts/form/expenses.html.erb @@ -2,7 +2,6 @@