I have this rails controller:
module Admin
module Settings
class PrintersController < ApplicationController # BaseController
end
end
end
I believe I should be able to match a layout for it as
app/views/layouts/admin/settings.html.erb
but this does not work. I can get
app/views/layouts/admin/settings/printers.html.erb
to work but I want a common layout for all settings.
what am I doing wrong?
From the documentation:
Parent Namespaced Layouts: If a layout is not found at the controller level, Rails will then traverse up the namespace hierarchy, looking for layouts that match the parent namespaces. For instance, Admin::Products::ItemsController might look for app/views/layouts/admin/products.html.erb, and then app/views/layouts/admin.html.erb. This behavior is often utilized by defining a base controller for a namespace (e.g., Admin::BaseController) and specifying a layout within that base controller.
class SettingsController < ApplicationController; endand thenclass PrintersController < SettingsController? This seems like the easiest solution with the least amount of "magic" involved.layoutwould solve this problem promptly and with significantly more clarity in the future.