title: rails - how to target nested controller for nested resource route
body: <p>In my <code>routes.rb</code> I have</p>
  
  <pre><code>namespace :admin do
    resources :clients do, only: [:index] do
      resources :products, only: [:index, :new, :create]
    end
  
    resources :products, only: [:index]
  end
  </code></pre>
  
  <p>Notice that I have two lines for <code>resources :products</code>. One is nested within <code>resources :clients</code> and the other as a top-level resource on <code>:admin</code>; each of these two has a different purpose in the application.</p>
  
  <p><code>rake routes</code> gives me:</p>
  
  <pre><code>           admin_clients GET  /admin/clients(.:format)                         admin/clients#index
     admin_client_products GET  /admin/clients/:client_id/products(.:format)     admin/products#index
                           POST /admin/clients/:client_id/products(.:format)     admin/products#create
  new_admin_client_product GET  /admin/clients/:client_id/products/new(.:format) admin/products#new
            admin_products GET  /admin/products(.:format)                        admin/products#index                    
  </code></pre>
  
  <p>I have a <code>admin_client_products</code> for the nested <code>product#index</code> resource. I also have <code>admin_products</code> for the top-level <code>product#index</code> resource. However, they point to the same controller action: <code>admin/product#index</code>.</p>
  
  <p>Question: At this point, I need rails to deduce that these are two different actions. Using rails conventions, is there a way to tell rails that these two resources should have different controller actions i.e. one that should hit <code>admin/products#index</code> and the other should hit <code>admin/clients/products#index</code>?</p>
  
  <p>The nested route should hit this:</p>
  
  <pre><code>class Admin::Clients::ProductsController &lt; Admin::BaseController      
    def index; end
  end
  </code></pre>
  
  <p>The top-level route should hit this:</p>
  
  <pre><code>class Admin::ProductsController &lt; Admin::BaseController      
    def index; end
  end
  </code></pre>