title: Rails routing for top-level inside a scope and resource
body: <p>In my Rails application I have the following controllers:</p>
  
  <pre><code>/controllers/journeys_controller.rb
  /controllers/policies/journeys_controller.rb
  /controllers/policies/drivers/journeys_controller.rb
  /controllers/policies/vehicles/journeys_controller.rb
  </code></pre>
  
  <p>And the code for them is as:</p>
  
  <pre><code>class JourneysController &lt; ApplicationController
  
      def custom_1; end
  
      def custom_2; end
  
  end
  
  module Policies
      class JourneysController &lt; ApplicationController
  
          def index; end
  
          def show; end
  
      end
  end
  
  module Policies
      module Drivers
          class JourneysController &lt; ApplicationController
  
              def index; end
  
              def show; end
  
          end
      end
  end
  
  module Policies
      module Vehicles
          class JourneysController &lt; ApplicationController
  
              def index; end
  
              def show; end
  
          end
      end
  end
  </code></pre>
  
  <p>So as you can see I have methods to list and show journeys for policies, drivers, and vehicles. And then I have custom methods for a journey at a top-level journeys controller.</p>
  
  <p>The routes I have so far are:</p>
  
  <pre><code>resources :policies, only: %i[index show] do
    scope module: :policies do
      resources :journeys, only: %i[index show] do
        get 'custom_1' =&gt; 'journeys#custom_1'
        get 'custom_2' =&gt; 'journeys#custom_2'
      end
      scope module: :drivers do
        resources :journeys, only: %i[index show] do
          get 'custom_1' =&gt; 'journeys#custom_1'
          get 'custom_2' =&gt; 'journeys#custom_2'
        end
      end
      scope module: :vehicles do
        resources :journeys, only: %i[index show] do
          get 'custom_1' =&gt; 'journeys#custom_1'
          get 'custom_2' =&gt; 'journeys#custom_2'
        end
      end
    end
  end
  </code></pre>
  
  <p>However those custom routes are not pointing at the top-level controller:</p>
  
  <p><a href="https://i.stack.imgur.com/5pZuj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5pZuj.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/QgXXK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QgXXK.png" alt="enter image description here"></a></p>
  
  <p>They are in fact pointing at their parent scope (which makes sense). But in my case I want to point those custom methods at the top-level. How can I make those routes point to a different controller but keep them nested so that the URLs stay in tact.</p>