title: remove the need for main_app prefix in path helpers in main app
body: <p>I've got an isolated, mountable rails engine which mounts itself in a namespace that is already declared in the host application. Here's how it looks more or less:</p>
  
  <p>routes.rb in the plugin:</p>
  
  <pre><code># my_engine/config/routes.rb 
  MyEngine::Engine.routes.draw do
    namespace :admin do
      resources :some_resource
    end
  end
  </code></pre>
  
  <p>And the appropriate snippet from the host app's routes.rb:</p>
  
  <pre><code># config/routes.rb
  mount MyEngine::Engine, at: "/"
  
  namespace :admin do
    resources :host_resource
  end
  </code></pre>
  
  <p>I'm mounting the engine at <code>/</code> since there are some routes in the engine that should be available there, and the admin namespaces overlap is intentional.</p>
  
  <p>These routes generates several path helpers, including <code>my_engine.admin_some_resources_path</code> and what I would expect to be <code>admin_host_resources_path</code>. The latter is what doesn't work.</p>
  
  <p>Assume there's a controller in the main application that is declared so:</p>
  
  <pre><code># app/controllers/admin/application_controller.rb
  class Admin::ApplicationController &lt; ApplicationController
    layout 'admin'
  end
  </code></pre>
  
  <p>And the engine's AdminController is declared in such a way as to inherit from it:</p>
  
  <pre><code># my_engine/app/controlles/admin/application_controller.rb
  class MyEngine::Admin::ApplicationController &lt; Admin::ApplicationController
  end
  </code></pre>
  
  <p>So far, all that works as expected. Now, assume that in the main application's <code>admin</code> layout, referenced from the Admin::ApplicationController, I try to use something essentially like:</p>
  
  <pre><code># app/views/layouts/admin.html.erb
  &lt;%= link_to "Host resources", admin_host_resources_path %&gt;
  &lt;%= link_to "Plugin's resources", my_engine.admin_some_resources_path %&gt;
  </code></pre>
  
  <p>This works fine when I load a path like '/admin/host_resources' - it renders the admin layout from the main application no problem. When opening the path '/admin/some_resources' - which goes into the plugin - it stops working complaining that <code>admin_host_resources_path</code> was not found. It starts working when I change it to this:</p>
  
  <pre><code># app/views/layouts/admin.html.erb
  &lt;%= link_to "Host resources", main_app.admin_host_resources_path %&gt;
  &lt;%= link_to "Plugin's resources", my_engine.admin_some_resources_path %&gt;
  </code></pre>
  
  <p>Which is not what I want, nor is it what I expect. Also I've seen enough rails plugins to know that this shouldn't be necessary, but after reading the Engines documentation I'm still at a loss. I've also scoured Stack, but to no avail. My question is: <strong>how to include the main_app helpers so that the prefix main_app is no longer needed</strong>?</p>
  
  <p>It's worth noting that the views for host_resource are in the main application itself, while the views for some_resource are in the engine. This shouldn't matter though, since the view which doesn't work is the <code>admin</code> layout in the main application.</p>
  
  <p>Also excuse the heavily anonymised code, but this is required of me.</p>