Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:06:28+00:00 2026-06-02T09:06:28+00:00

I’m struggling to understand how Rails 3.2 applies layouts when using mountable engines. Scenario:

  • 0

I’m struggling to understand how Rails 3.2 applies layouts when using mountable engines.

Scenario: I’m building an engine which itself has a dashboard view and an admin view for various admin functions. I want the dashboard to have its layout overridable by the base application (if the user desires) but the admin should always use its own layout.

Here’s what I have at the moment inside my engine;

application_controller.rb

module Myengine
  class ApplicationController < ActionController::Base

admin/dashboard_controller.rb

module Myengine                                                                                                          
  class Admin::DashboardController < ApplicationController

now I have my engines application.html.erb apply a hideous Red background whilst the base applications application.html.erb uses a pleasant yellow background so I can distinguish which application layout is being applied.

In this situation, if I access the base application first I see my yellow background (from the base app) and if I go to both the engine and the engines admin path the yellow background remains.

If I restart the server and access the engine first then I see the red background for the engine and the engines admin path whilst the base application shows the yellow background.

If I modify my admin/dashboard_controller.rb as follows;

module Myengine
  class Admin::DashboardController < ApplicationController
    layout 'myengine/application'

which I would expect to only apply to the engine/admin controller – but if I restart the server and access the engine/admin path I see the red background whilst the root view of the engine uses the base application yellow layout.

If I restart the server again and access the root of the mounted engine I get the red background applied which remains on the engines admin path too.

Aaaaarggggghhhhh!

Is it expected behaviour to have different layouts of the application used depending on which path of the application is accessed first? Surely not?? I must be doing something wrong!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:06:29+00:00Added an answer on June 2, 2026 at 9:06 am

    I’ve debugged the problem and actually it’s not a bug in Engines. The problem is caused by the way rails dependencies are loaded.

    This code will behave differently in 2 scenarios that you’re showing:

    module Enginedemo
      class DashboardController < ApplicationController
      end
    end
    

    If ApplicationController is already loaded, rails will assume that we just want to use it and you will actually not inherit from Enginedemo::ApplicationController but from ApplicationController. In the other scenario, when you first load engine’s controller, ApplicationController is not loaded yet, so Rails does the right thing.

    Thankfully this problem occurs only in development environment as in production controllers are loaded when application is booting.

    I’m not sure if this is something that can be easily fixed in rails dependencies, I will take a look at it.

    For now, please explicitly require application controller:

    require 'enginedemo/application_controller'
    
    module Enginedemo
      class DashboardController < ApplicationController
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.