Browse Source

feat: wip commit error messages

pull/954/head
natdeanlewissoftwire 3 years ago
parent
commit
c4a45482c8
  1. 9
      app/controllers/organisation_relationships_controller.rb
  2. 5
      app/views/organisation_relationships/add_housing_provider.html.erb

9
app/controllers/organisation_relationships_controller.rb

@ -29,6 +29,11 @@ class OrganisationRelationshipsController < ApplicationController
end end
def create def create
@resource = OrganisationRelationship.new
if params["related_organisation_id"] == nil
@resource.errors.add :housing_providers, "Select a housing provider"
return
end
@resource = OrganisationRelationship.new(child_organisation_id: @organisation.id, parent_organisation_id: related_organisation_params, relationship_type: 0) @resource = OrganisationRelationship.new(child_organisation_id: @organisation.id, parent_organisation_id: related_organisation_params, relationship_type: 0)
@resource.save! @resource.save!
redirect_to housing_providers_organisation_path redirect_to housing_providers_organisation_path
@ -40,10 +45,6 @@ private
@organisation ||= Organisation.find(params[:id]) @organisation ||= Organisation.find(params[:id])
end end
def related_organisation
Organisation.find(params[:related_organisation_id])
end
def related_organisation_params def related_organisation_params
params.require(:related_organisation_id) params.require(:related_organisation_id)
end end

5
app/views/organisation_relationships/add_housing_provider.html.erb

@ -1,6 +1,5 @@
<%= form_with url: housing_providers_organisation_path, method: "post", local: true do |f| %> <%= form_with model: @organisation, url: housing_providers_organisation_path, method: "post", local: true do |f| %>
<%# remove_other_page_errors(@log, @page) %> <%= f.govuk_error_summary %>
<%#= f.govuk_error_summary %>
<% if current_user.support? %> <% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>

Loading…
Cancel
Save