Set engine layout on ApplicationController#72
Open
fcatuhe wants to merge 1 commit intofractaledmind:mainfrom
Open
Set engine layout on ApplicationController#72fcatuhe wants to merge 1 commit intofractaledmind:mainfrom
fcatuhe wants to merge 1 commit intofractaledmind:mainfrom
Conversation
Without an explicit layout declaration, Litestream::ApplicationController inherits the layout from its base_controller_class. When the base controller declares its own layout (e.g. `layout "admin"`), Litestream renders inside the host app's layout, which breaks because main app route helpers are not available inside mounted engine views (NameError). This matches what other Rails engine dashboards do: - mission_control-jobs: `layout "mission_control/jobs/application"` - audits1984: `layout "audits1984/application"` - blazer: `layout "blazer/application"` The litestream/application layout already exists — it just was never declared on the controller.
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.
Problem
When
base_controller_classis configured to a controller that declares its own layout (e.g.layout "admin"),Litestream::ApplicationControllerinherits that layout. Since the host app's layout uses route helpers that aren't available inside a mounted engine, this causes aNameError:Root cause
Litestream::ApplicationControllerdoesn't declare its own layout. Thelitestream/applicationlayout file exists, but without an explicitlayoutdeclaration on the controller, Rails resolves the layout from the parent class.Fix
Add
layout "litestream/application"toLitestream::ApplicationController. This matches what other Rails engine dashboards do:mission_control-jobs:layout "mission_control/jobs/application"audits1984:layout "audits1984/application"blazer:layout "blazer/application"Tests
litestream/applicationregardless of the base controller's layout<title>Litestream</title>, not the host app'sMyApplicationControllernow setslayout "application"to exercise this scenario