I'm building an application that has a mountable but not isolated rails engine located at APP/sites/my_engine/. My understanding of a typical request with this setup looks like this:
- A request goes through the Main App's middleware stack.
- The request hit's the Main App's router, and matches the mounted path. It places the mounted part in: env["SCRIPT_NAME"] and sends the request on through the Engine.
- The request goes through the Engine's middleware stack.
- The request hit's the Engine's router and matches the remaining portion of the route.
Let's say that the route matches in the engine's routes and dispatches to a pages#show action. A controller will be called with the following priority:
- If a PagesController exists with the show action in the main app it will call this first.
- If a PagesController exists with the show action in the engine it will call this second only if the first did not exist.
If you look at MyEngine::Engine.paths['app/controllers'] it is the default ["app/controllers"]..which in this context is the engine. So why does it find the App's controller first?
Where is this priority of paths for controllers controlled?