title: Rails 3 Routing - specifying an exact controller from within a namespace
body: <p>I'm having a bit of a problem with route namespaces that I've not encountered before. This is actually a part of some gem development I'm doing - but i've reworked the problem to fit with a more generic rails situation.</p>
  
  <p>Basically, I have a namespaced route, but I want it to direct to a generic (top-level) controller.</p>
  
  <p>My controller is <code>PublishController</code>, which handles publishing of many different types of Models - which all conform to the same interface, but can be under different namespaces. My routes look like this:</p>
  
  <pre><code># config/routes.rb
  
  namespace :manage do
    resources :projects do
      get 'publish' =&gt; 'publish#create'
      get 'unpublish' =&gt; 'publish#destroy'
    end
  end
  </code></pre>
  
  <p>The problem is that this creates the following routes:</p>
  
  <pre><code>manage_project_publish GET    /manage/projects/:project_id/publish(.:format)        {:controller=&gt;"manage/publish", :action=&gt;"create"}
  manage_project_unpublish GET    /manage/projects/:project_id/unpublish(.:format)      {:controller=&gt;"manage/publish", :action=&gt;"destroy"}
  </code></pre>
  
  <p>Which is the routes I want, just not mapping to the correct controller. I've tried everything I can think of try and allow for the controller not to carry the namespace, but I'm stumped.</p>
  
  <p>I know that I <em>could</em> do the following:</p>
  
  <pre><code>get 'manage/features/:feature_id/publish' =&gt; "publish#create", :as =&gt; "manage_project_publish"
  </code></pre>
  
  <p>which produces:</p>
  
  <pre><code>manage_project_publish GET    /manage/projects/:project_id/publish(.:format)        {:controller=&gt;"publish", :action=&gt;"create"}
  </code></pre>
  
  <p>but ideally, I'd prefer to use the nested declaration (for readability) - if it's even possible; which I'm starting to think it isn't.</p>