Skip to content

Fix NameError when the engine is mounted under a named scope or custom as: - #1

Merged
cmer merged 1 commit into
mainfrom
fix/engine-route-helper-proxy
Jul 28, 2026
Merged

Fix NameError when the engine is mounted under a named scope or custom as:#1
cmer merged 1 commit into
mainfrom
fix/engine-route-helper-proxy

Conversation

@cmer

@cmer cmer commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix every page raising NameError: undefined local variable or method 'flightdeck' when the engine is mounted inside a named scope/namespace (route name becomes e.g. admin_flightdeck) or with a custom as: — the layout and asset helper referenced routes through the host's mounted-route proxy, whose method name is derived from the mount's route name, not the engine.
  • Call the URL helpers bare (root_path, jobs_path, asset_file_path, …): as an isolated engine, they resolve against the engine's own route set with the request's script name, so every mount shape works.
  • Restructure the dummy app to mount the engine three ways — plain, inside namespace :admin, and as: :renamed at /ops/dash (a path with no flightdeck tail, so Rails' script-name merging can't mask a wrong-mount URL) — and extend the nested-mount suite to cover the renamed mount.
  • Add a subprocess boot test reproducing the real-world breakage: a host whose only mount is namespaced (no flightdeck proxy method exists in the process), with a conflicting host-level jobs_path, under base_controller_class inheritance — proving the engine's helpers still win.
  • Bump version to 0.5.2, add a CHANGELOG entry under Fixed, and rebuild the committed assets (the JS banner embeds the version).

Testing

  • bin/test (full suite in both host modes: 261 runs / 0 failures each)
  • bundle exec rubocop (no offenses)

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@cmer
cmer merged commit 3789255 into main Jul 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant