diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index c5249f5ee..f31662c4f 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -44,8 +44,8 @@ class FormController < ApplicationController end end flash[:log_data] = responses_for_page - question_ids = (log.errors.map(&:attribute) - [:base]).uniq - flash[:pages_with_errors_count] = question_ids.map { |id| log.form.get_question(id, log)&.page&.id }.compact.uniq.count + question_ids = (@log.errors.map(&:attribute) - [:base]).uniq + flash[:pages_with_errors_count] = question_ids.map { |id| @log.form.get_question(id, @log)&.page&.id }.compact.uniq.count redirect_to send("#{@log.class.name.underscore}_#{@page.id}_path", @log, { referrer: request.params["referrer"], original_page_id: request.params["original_page_id"], related_question_ids: request.params["related_question_ids"] }) end else diff --git a/spec/views/form/page_view_spec.rb b/spec/views/form/page_view_spec.rb index c301d5156..83f76572f 100644 --- a/spec/views/form/page_view_spec.rb +++ b/spec/views/form/page_view_spec.rb @@ -29,7 +29,7 @@ RSpec.describe "form/page" do assign(:log, lettings_log) assign(:page, page) assign(:subsection, subsection) - assign(:questions_with_errors_count, 0) + assign(:pages_with_errors_count, 0) assign_attributes(page, page_attributes) assign_attributes(question, question_attributes) render