From c5997981c41b37339d1b9744b3d7b78aeddd78b0 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 28 Sep 2022 12:30:47 +0100 Subject: [PATCH] update routes --- app/controllers/form_controller.rb | 2 +- app/helpers/tasklist_helper.rb | 2 +- app/models/form.rb | 2 +- config/routes.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 6b325f390..c2827fdb9 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -13,7 +13,7 @@ class FormController < ApplicationController session[:errors] = session[:fields] = nil redirect_to(successful_redirect_path) else - redirect_path = @log.not_started? ? "#{@log.model_name.param_key}s_new_#{@page.id}_path" : "#{@log.model_name.param_key}_#{@page.id}_path" + redirect_path = @log.not_started? ? "#{@log.model_name.param_key}_new_#{@page.id}_path" : "#{@log.model_name.param_key}_#{@page.id}_path" mandatory_questions_with_no_response.map do |question| @log.errors.add question.id.to_sym, question.unanswered_error_message end diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index 27a4959bb..bf8d4ae1e 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -20,7 +20,7 @@ module TasklistHelper if log.id send(path, log) else - "/#{log.lettings? ? 'lettings' : 'sales'}-logs/new/#{next_question_page(subsection, log, current_user)}" + "/#{log.class.name.underscore.dasherize}/new/#{next_question_page(subsection, log, current_user)}" end end diff --git a/app/models/form.rb b/app/models/form.rb index f73e5348f..fa83588ae 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -76,7 +76,7 @@ class Form if nxt_page == :check_answers "#{type}_log_#{subsection_for_page(page).id}_check_answers_path" else - log.id ? "#{type}_log_#{nxt_page}_path" : "#{type}_logs_new_#{nxt_page}_path" + log.id ? "#{type}_log_#{nxt_page}_path" : "#{type}_log_new_#{nxt_page}_path" end end diff --git a/config/routes.rb b/config/routes.rb index f6953389f..6c9deedb1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,8 +31,8 @@ Rails.application.routes.draw do FormHandler.instance.forms.each do |_key, form| form.pages.map do |page| - get "/lettings-logs/new/#{page.id.to_s.dasherize}", to: "form#show_page" - get "/sales-logs/new/#{page.id.to_s.dasherize}", to: "form#show_page" + get "/lettings-log/new/#{page.id.to_s.dasherize}", to: "form#show_page" + get "/sales-log/new/#{page.id.to_s.dasherize}", to: "form#show_page" end end