From 87f58356ce4493b8fb77474a904ffc91d7f1987c Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 1 Aug 2022 15:26:33 +0100 Subject: [PATCH] Use path helpers --- app/helpers/check_answers_helper.rb | 4 ++-- app/views/locations/edit.html.erb | 4 +++- config/routes.rb | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index f5233d33a..760c08ab0 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -18,9 +18,9 @@ module CheckAnswersHelper def get_location_change_link_href(scheme, location) if location.confirmed? - "/schemes/#{scheme.id}/locations/#{location.id}/edit-name" + location_edit_name_path(id: scheme.id, location_id: location.id) else - "/schemes/#{scheme.id}/locations/#{location.id}/edit" + location_edit_path(id: scheme.id, location_id: location.id) end end diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 6fe2496b2..77eb96bb4 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -7,7 +7,9 @@ ) %> <% end %> -<%= form_for(@location, method: :patch, url: location_path) do |f| %> +<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %> + +<%= form_for(@location, method: :patch, url: location_path(location_id: @location.id)) do |f| %>
<%= f.govuk_error_summary %> diff --git a/config/routes.rb b/config/routes.rb index a6b0b9654..65130cd35 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,6 +48,7 @@ Rails.application.routes.draw do member do resources :locations do get "edit-name", to: "locations#edit_name" + get "edit", to: "locations#edit" end end end