From baf1e60451ddf04bbe57915f309e380c0963384b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Catuhe?= Date: Wed, 25 Feb 2026 10:11:16 +0100 Subject: [PATCH] Set engine layout on ApplicationController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/controllers/litestream/application_controller.rb | 2 ++ test/controllers/test_processes_controller.rb | 1 + test/dummy/app/controllers/my_application_controller.rb | 1 + test/litestream/test_base_application_controller.rb | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/app/controllers/litestream/application_controller.rb b/app/controllers/litestream/application_controller.rb index b3f0582..9813e56 100644 --- a/app/controllers/litestream/application_controller.rb +++ b/app/controllers/litestream/application_controller.rb @@ -1,5 +1,7 @@ module Litestream class ApplicationController < Litestream.base_controller_class.constantize + layout "litestream/application" + protect_from_forgery with: :exception if Litestream.password diff --git a/test/controllers/test_processes_controller.rb b/test/controllers/test_processes_controller.rb index 3f15a6e..80432f1 100644 --- a/test/controllers/test_processes_controller.rb +++ b/test/controllers/test_processes_controller.rb @@ -21,6 +21,7 @@ class Litestream::TestProcessesController < ActionDispatch::IntegrationTest Litestream.stub :databases, stubbed_databases do get litestream.process_url assert_response :success + assert_select "title", "Litestream" assert_select "#process_12345", 1 do assert_select "small", "sleeping" diff --git a/test/dummy/app/controllers/my_application_controller.rb b/test/dummy/app/controllers/my_application_controller.rb index 2aa9205..9195d2f 100644 --- a/test/dummy/app/controllers/my_application_controller.rb +++ b/test/dummy/app/controllers/my_application_controller.rb @@ -1,2 +1,3 @@ class MyApplicationController < ApplicationController + layout "application" end diff --git a/test/litestream/test_base_application_controller.rb b/test/litestream/test_base_application_controller.rb index d7e2e10..32df1f3 100644 --- a/test/litestream/test_base_application_controller.rb +++ b/test/litestream/test_base_application_controller.rb @@ -8,4 +8,8 @@ class Litestream::BaseApplicationControllerTest < ActiveSupport::TestCase test "engine's ApplicationController inherits from configured base_controller_class" do assert Litestream::ApplicationController < MyApplicationController end + + test "engine's ApplicationController uses its own layout regardless of base controller layout" do + assert_equal "litestream/application", Litestream::ApplicationController._layout + end end