|
|
|
|
@ -49,15 +49,15 @@ class OrganisationRelationshipsController < ApplicationController
|
|
|
|
|
if related_organisation_id.empty? |
|
|
|
|
@organisation.errors.add :related_organisation_id, "You must choose a housing provider" |
|
|
|
|
@organisations = Organisation.where.not(id: child_organisation_id).pluck(:id, :name) |
|
|
|
|
render 'organisation_relationships/add_housing_provider' |
|
|
|
|
render "organisation_relationships/add_housing_provider" |
|
|
|
|
return |
|
|
|
|
elsif OrganisationRelationship.exists?(child_organisation_id:, parent_organisation_id:, relationship_type:) |
|
|
|
|
@organisation.errors.add :related_organisation_id, "You have already added this housing provider" |
|
|
|
|
@organisations = Organisation.where.not(id: child_organisation_id).pluck(:id, :name) |
|
|
|
|
render 'organisation_relationships/add_housing_provider' |
|
|
|
|
render "organisation_relationships/add_housing_provider" |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
create(child_organisation_id:, parent_organisation_id:, relationship_type:) |
|
|
|
|
create!(child_organisation_id:, parent_organisation_id:, relationship_type:) |
|
|
|
|
redirect_to housing_providers_organisation_path(related_organisation_id:) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|