From 576cf02cda6fd12ce63d6c59cc0f0a6abfcaeddc Mon Sep 17 00:00:00 2001 From: Brock Wilcox Date: Sun, 19 Jul 2026 11:24:59 -0400 Subject: [PATCH] Replace broken Log out link on static error pages with a Home link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The static error pages (403/404/422/500) had a logout link relying on data-method="delete", which needs rails-ujs — JavaScript those static pages never load. Clicking it degraded to GET /users/sign_out, which has no route. Rather than adding a GET sign-out route (a logout-CSRF vector that link prefetchers can also trigger), this drops the logout button completely. Instead we'll look back to home/dashboard and as long as the whole app isn't crashed then they can log out from there. --- public/403.html | 4 ++-- public/404.html | 4 ++-- public/422.html | 4 ++-- public/500.html | 4 ++-- spec/features/error_pages_spec.rb | 26 ++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 spec/features/error_pages_spec.rb diff --git a/public/403.html b/public/403.html index 233a2b2e47..d4b0758262 100644 --- a/public/403.html +++ b/public/403.html @@ -34,7 +34,7 @@ @@ -63,7 +63,7 @@

403 Error Page

diff --git a/public/404.html b/public/404.html index bb6356bebd..3bc017e56a 100644 --- a/public/404.html +++ b/public/404.html @@ -35,7 +35,7 @@ @@ -64,7 +64,7 @@

404 Error Page

diff --git a/public/422.html b/public/422.html index 057cb5032c..4d827e875f 100644 --- a/public/422.html +++ b/public/422.html @@ -33,7 +33,7 @@ @@ -62,7 +62,7 @@

422 Error Page

diff --git a/public/500.html b/public/500.html index b589b6445c..d1c381b2e6 100644 --- a/public/500.html +++ b/public/500.html @@ -33,7 +33,7 @@ @@ -62,7 +62,7 @@

500 Error Page

diff --git a/spec/features/error_pages_spec.rb b/spec/features/error_pages_spec.rb new file mode 100644 index 0000000000..7eca94ff5b --- /dev/null +++ b/spec/features/error_pages_spec.rb @@ -0,0 +1,26 @@ +require "rails_helper" + +RSpec.describe "Static error pages", type: :feature do + let(:user) { create(:user) } + + %w[403 404 422 500].each do |code| + context "on the #{code} error page" do + it "offers a Home link instead of a log out link" do + sign_in(user) + visit "/#{code}" + + expect(page).to have_no_link("Log out") + + click_link "Home", match: :first + expect(page).to have_current_path(dashboard_path) + end + + it "sends signed-out visitors home to the landing page" do + visit "/#{code}" + + click_link "Home", match: :first + expect(page).to have_current_path(root_path) + end + end + end +end