From 6709213ffd835ad99d91455f6e841c7490b25285 Mon Sep 17 00:00:00 2001 From: aaaaargZombies <6824891+aaaaargZombies@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:13:38 +0100 Subject: [PATCH] fix: prevent duplicate service_area crashing placeca when creating a new partner --- app/controllers/admin/partners_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/admin/partners_controller.rb b/app/controllers/admin/partners_controller.rb index 6d311e66f..b6ef8bc2e 100644 --- a/app/controllers/admin/partners_controller.rb +++ b/app/controllers/admin/partners_controller.rb @@ -39,6 +39,9 @@ def create authorize @partner + # prevent someone trying to add the same service_area twice by mistake and causing a crash + @partner.service_areas = @partner.service_areas.uniq { |service_area| service_area.neighbourhood_id } + respond_to do |format| if @partner.save format.html do