title: Rails 3 - Controller/View Subdirectories Routing
body: <p>I have some controllers separated out into subdirectories like:</p>
  
  <pre><code>app/dept1/user_controller/action
  </code></pre>
  
  <p>With this configuration in the controller:</p>
  
  <pre><code>class Dept1::UserController &lt; ApplicationController
  end
  </code></pre>
  
  <p>In rails 2, that's all I needed to do and the application was able to auto-route just fine.</p>
  
  <p>But in rails 3, it appears I need to do some routing configurations. I've tried using namespaces:</p>
  
  <pre><code>  namespace :dept1 do
      resources :user
    end
  </code></pre>
  
  <p>This page pulls up fine:</p>
  
  <pre><code>app/dept1/user_controller/index
  </code></pre>
  
  <p>But app/dept1/user_controller/report returns this error:</p>
  
  <pre><code> "ActionController::RoutingError (No route matches [POST] "/dept1/user/report")"
  </code></pre>
  
  <p>What else do I need to configure?</p>
  
  <p>UPDATE:</p>
  
  <p>When I put this in my routes, it works:</p>
  
  <pre><code>namespace :dept1 do
    resources :user do
      collection do
        get :report
        post :report
      end
    end
  end
  </code></pre>
  
  <p>Is there a way I can do this without hardcoding each action?</p>
  
  <p>MORE UPDATES:</p>
  
  <p>Here's what I did to fix the routes to work right. It must be in this order:</p>
  
  <pre><code>match ':controller(/:action(/:id))', :controller =&gt; /dept1\/[^\/]+/
  match ':controller(/:action(/:id(.:format)))'
  </code></pre>