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)) %>

Remove Housing Provider

<% end %> - <% @housing_provider = Organisation.find(@target_organisation_id) %> + <% @housing_provider = @target_organisation %> <% if current_user.support? %> <%= govuk_back_link(href: :back) %> <%= render partial: "organisations/headings", locals: { main: "You are removing ‘#{@housing_provider.name}’ from this organisation's housing providers", sub: nil } %> diff --git a/db/schema.rb b/db/schema.rb index 02c7f3d90..ebe7598a5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -359,8 +359,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_19_082625) do t.integer "hholdcount" t.integer "age3" t.integer "age3_known" - t.integer "income1" - t.integer "income1nk" t.integer "age4" t.integer "age4_known" t.integer "age5" @@ -369,6 +367,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_19_082625) do t.integer "age6_known" t.string "la" t.integer "la_known" + t.integer "income1" + t.integer "income1nk" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"