From 6711227147b3d886e57820672f24d2eef786df87 Mon Sep 17 00:00:00 2001 From: Carl Mercier Date: Mon, 27 Jul 2026 23:24:19 -0500 Subject: [PATCH] Resolve engine routes without the host's mounted-route proxy The layout and asset helper called route helpers through the host's mounted-route proxy, hardcoded as `flightdeck`. That method's name is derived from the mount's route name, so mounting the engine inside a named scope (route name admin_flightdeck) or with a custom `as:` made every page raise NameError. As an isolated engine, bare helpers already resolve against the engine's routes with the request's script name, so call them directly. The dummy app now mounts the engine three ways (plain, namespaced, renamed at a path with no shared tail, so script-name merging cannot mask a wrong-mount URL), and a subprocess boot test reproduces the real breakage: a host whose only mount is namespaced, with a conflicting host-level jobs_path, under base_controller_class inheritance. Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 6 +++ Gemfile.lock | 4 +- ...423da15f.js => flightdeck-747ab6d1a6fa.js} | 4 +- app/assets/flightdeck/manifest.json | 6 +-- app/helpers/flightdeck/application_helper.rb | 2 +- .../layouts/flightdeck/application.html.erb | 14 +++--- lib/flightdeck/version.rb | 2 +- test/boot_test.rb | 31 +++++++++++- test/dummy/config/routes.rb | 42 +++++++++++++---- test/integration/nested_mount_test.rb | 47 +++++++++++++++++-- test/support/probe.rb | 11 +++-- 11 files changed, 137 insertions(+), 32 deletions(-) rename app/assets/flightdeck/{flightdeck-8fc2423da15f.js => flightdeck-747ab6d1a6fa.js} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 695f582..b487c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + +- The dashboard no longer 500s when the engine is mounted under a named scope + or namespace (e.g. `namespace :admin { mount Flightdeck::Engine, at: "/jobs" }`) + or with a custom route name via `as:`. + ## [0.5.1] - 2026-07-27 ### Added diff --git a/Gemfile.lock b/Gemfile.lock index 685f8cd..54660bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - flightdeck (0.5.1) + flightdeck (0.5.2) rails (>= 7.1) solid_queue (>= 1.0) @@ -357,7 +357,7 @@ CHECKSUMS erb (6.0.6) sha256=a9b24986700f5bf127c4f297c5403c3ca41b83b0a316c0cd09a096b56e644ae5 erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 et-orbi (1.4.0) sha256=6c7e3c90779821f9e3b324c5e96fda9767f72995d6ae435b96678a4f3e2de8bc - flightdeck (0.5.1) + flightdeck (0.5.2) fugit (1.13.0) sha256=a4f093fce740da52f216740a5041e2a594ea763cdb89e8b2754ca4399634ab18 globalid (1.4.0) sha256=037f12fbf1d9d7a014d501c2d5c77356fd4ddd96d7a7991d6700bba96706f427 i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5 diff --git a/app/assets/flightdeck/flightdeck-8fc2423da15f.js b/app/assets/flightdeck/flightdeck-747ab6d1a6fa.js similarity index 99% rename from app/assets/flightdeck/flightdeck-8fc2423da15f.js rename to app/assets/flightdeck/flightdeck-747ab6d1a6fa.js index 2152186..69dbb0b 100644 --- a/app/assets/flightdeck/flightdeck-8fc2423da15f.js +++ b/app/assets/flightdeck/flightdeck-747ab6d1a6fa.js @@ -1,4 +1,4 @@ -/* Flightdeck 0.5.1 — bundled @hotwired/turbo + @hotwired/stimulus. Generated by `rake assets:build`; do not edit. */ +/* Flightdeck 0.5.2 — bundled @hotwired/turbo + @hotwired/stimulus. Generated by `rake assets:build`; do not edit. */ (function(){ /** * Minified by jsDelivr using Terser v5.39.0. @@ -408,7 +408,7 @@ class ToastController extends Stimulus.Controller { application.register("theme", ThemeController) application.register("toast", ToastController) - window.Flightdeck = { application: application, version: "0.5.1" } + window.Flightdeck = { application: application, version: "0.5.2" } })() })(); diff --git a/app/assets/flightdeck/manifest.json b/app/assets/flightdeck/manifest.json index 16f45e6..269ef65 100644 --- a/app/assets/flightdeck/manifest.json +++ b/app/assets/flightdeck/manifest.json @@ -7,9 +7,9 @@ "size": 118411 }, "flightdeck.js": { - "file": "flightdeck-8fc2423da15f.js", - "digest": "8fc2423da15f", - "sha256": "8fc2423da15f28fd3fcfd89fa820027ab955bdb902377c58d225b7fd81617b25", + "file": "flightdeck-747ab6d1a6fa.js", + "digest": "747ab6d1a6fa", + "sha256": "747ab6d1a6fafd8eb6ff4eca9f487ad62a11fdb0df52e8293db0d2699a575dcd", "content_type": "text/javascript; charset=utf-8", "size": 150889 } diff --git a/app/helpers/flightdeck/application_helper.rb b/app/helpers/flightdeck/application_helper.rb index 907372e..49de035 100644 --- a/app/helpers/flightdeck/application_helper.rb +++ b/app/helpers/flightdeck/application_helper.rb @@ -9,7 +9,7 @@ def flightdeck_asset_path(logical_name) digested = Flightdeck::Assets.digested_name(logical_name) return nil unless digested - flightdeck.asset_file_path(name: digested) + asset_file_path(name: digested) end # Sidebar counts are capped like every other count, and degrade to "—" diff --git a/app/views/layouts/flightdeck/application.html.erb b/app/views/layouts/flightdeck/application.html.erb index d910059..11c7b42 100644 --- a/app/views/layouts/flightdeck/application.html.erb +++ b/app/views/layouts/flightdeck/application.html.erb @@ -4,7 +4,7 @@ <%= content_for?(:title) ? yield(:title) : "Flightdeck" %> - + <%= csrf_meta_tags %> <% if (css = flightdeck_asset_path("flightdeck.css")) %> @@ -22,36 +22,36 @@