Centralise the Inertia layout declaration - #1663
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a05ac9-1a64-75cf-adfd-ea503ca775ba Co-authored-by: Amp <amp@ampcode.com>
Greptile SummaryCentralizes the shared Inertia layout declaration in
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security issues identified. The centralized declaration preserves descendant Inertia rendering, while explicit JSON, redirect, and head responses continue to bypass layout rendering; the changed behavior is covered by focused request tests. Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
ApplicationController <|-- InertiaController
InertiaController : layout inertia
InertiaController <|-- ExtensionsController
InertiaController <|-- StaticPagesController
InertiaController <|-- UsersController
InertiaController <|-- AdminBaseController
InertiaController <|-- SettingsBaseController
Reviews (1): Last reviewed commit: "Centralise Inertia layout declaration" | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR centralises the Inertia layout configuration by declaring layout "inertia" once in InertiaController, removing duplicated (and sometimes scoped) layout declarations across descendant controllers, and adding integration coverage to ensure the layout is applied for Inertia responses without affecting JSON endpoints.
Changes:
- Declare
layout "inertia"inInertiaControlleras the single source of truth for the Inertia controller hierarchy. - Remove redundant
layout "inertia"declarations from descendant controllers. - Add an integration test covering a pure Inertia descendant and a mixed controller with both Inertia and JSON responses.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/controllers/inertia_controller_test.rb | Adds request coverage to verify the inherited Inertia layout renders expected HTML markers and does not wrap JSON responses. |
| app/controllers/inertia_controller.rb | Centralises layout "inertia" for all controllers inheriting from InertiaController. |
| app/controllers/users_controller.rb | Removes duplicated scoped layout declaration now covered by InertiaController. |
| app/controllers/static_pages_controller.rb | Removes duplicated scoped layout declaration now covered by InertiaController. |
| app/controllers/settings/base_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/profiles_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/my/project_repo_mappings_controller.rb | Removes duplicated scoped layout declaration now covered by InertiaController. |
| app/controllers/leaderboards_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/extensions_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/doorkeeper/applications_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/deletion_requests_controller.rb | Removes duplicated scoped layout declaration now covered by InertiaController. |
| app/controllers/api_keys_controller.rb | Removes duplicated scoped layout declaration now covered by InertiaController. |
| app/controllers/admin/leaderboard_shadowbans_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/admin/base_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
| app/controllers/admin/account_merger_controller.rb | Removes duplicated layout declaration now covered by InertiaController. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary of the problem
Controllers in the Inertia hierarchy repeat the same Rails layout declaration. Scoped declarations on mixed controllers make ownership less clear even though non-rendering actions do not apply layouts.
Describe your changes
Declare the layout once in
InertiaControllerand remove inherited duplicates. Keep declarations on controllers outside the hierarchy. Add request coverage for a pure descendant and a mixed descendant's Inertia and JSON responses.Screenshots / Media
Not applicable. No visual changes.