Fix NameError when the engine is mounted under a named scope or custom as: - #1
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 customas:— 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.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.namespace :admin, andas: :renamedat/ops/dash(a path with noflightdecktail, so Rails' script-name merging can't mask a wrong-mount URL) — and extend the nested-mount suite to cover the renamed mount.flightdeckproxy method exists in the process), with a conflicting host-leveljobs_path, underbase_controller_classinheritance — proving the engine's helpers still win.Testing
bin/test(full suite in both host modes: 261 runs / 0 failures each)bundle exec rubocop(no offenses)🤖 Generated with Claude Code