diff --git a/app/controllers/organisation_relationships_controller.rb b/app/controllers/organisation_relationships_controller.rb index 7ead349c6..50f256d81 100644 --- a/app/controllers/organisation_relationships_controller.rb +++ b/app/controllers/organisation_relationships_controller.rb @@ -83,9 +83,9 @@ class OrganisationRelationshipsController < ApplicationController end def delete_housing_provider - organisation_relationship_to_remove = OrganisationRelationship.find_by!(child_organisation_id: @organisation.id, parent_organisation_id: target_organisation_id, relationship_type: OrganisationRelationship::OWNING) + organisation_relationship_to_remove = OrganisationRelationship.find_by!(child_organisation: @organisation, parent_organisation: target_organisation, relationship_type: OrganisationRelationship::OWNING) organisation_relationship_to_remove.destroy! - flash[:notice] = "#{Organisation.find(target_organisation_id).name} is no longer one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers" + flash[:notice] = "#{target_organisation.name} is no longer one of #{current_user.data_coordinator? ? 'your' : "this organisation's"} housing providers" redirect_to housing_providers_organisation_path end @@ -104,8 +104,8 @@ private params["organisation"]["related_organisation_id"] end - def target_organisation_id - params["target_organisation_id"] + def target_organisation + @target_organisation ||= Organisation.find(params[:target_organisation_id]) end def search_term diff --git a/app/views/organisation_relationships/remove_housing_provider.html.erb b/app/views/organisation_relationships/remove_housing_provider.html.erb index 9c0fed118..dae769475 100644 --- a/app/views/organisation_relationships/remove_housing_provider.html.erb +++ b/app/views/organisation_relationships/remove_housing_provider.html.erb @@ -1,10 +1,10 @@ -<%= form_with url: housing_providers_organisation_path(target_organisation_id: @target_organisation_id), method: "delete", local: true do |f| %> +<%= form_with url: housing_providers_organisation_path(target_organisation: @target_organisation), method: "delete", local: true do |f| %> <% if current_user.support? %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>