title: Rails routing. Singular resource
body: <p>I've got Rails routing problem. I would like to use singular resource with user controller but it doesn't work as I expected. Here is the fragment of my routes.rb file:</p>
  
  <pre><code>scope :module =&gt; "frontend" do
    root :to =&gt; "home#index"
    resource :user, :controller =&gt; "user"
    get "/sign_up" =&gt; "user#new"
    get "/sign_in" =&gt; "user#sign_in"
    get "/sign_out" =&gt; "user#sign_out"
    post "/authenticate" =&gt; "user#authenticate"
    resources :articles
    resources :article_categories
  end
  </code></pre>
  
  <p>I thought it will work when I'll use for example "/user" or "/user/new" URL but it didn't. I get a routing error:</p>
  
  <pre><code>No route matches {:controller=&gt;"frontend/user"}
  </code></pre>
  
  <p>The 'rake routes' command output is:</p>
  
  <pre><code>     user POST   /user(.:format)          frontend/user#create
   new_user GET    /user/new(.:format)      frontend/user#new
  edit_user GET    /user/edit(.:format)     frontend/user#edit
            GET    /user(.:format)          frontend/user#show
            PUT    /user(.:format)          frontend/user#update
            DELETE /user(.:format)          frontend/user#destroy
    sign_up GET    /sign_up(.:format)       frontend/user#new
    sign_in GET    /sign_in(.:format)       frontend/user#sign_in
   sign_out GET    /sign_out(.:format)      frontend/user#sign_out
  </code></pre>
  
  <p>authenticate POST   /authenticate(.:format)  frontend/user#authenticate</p>
  
  <p>What is interesting, when I add route for index action in user controller, like this:</p>
  
  <pre><code>scope :module =&gt; "frontend" do
    root :to =&gt; "home#index"
    resource :user, :controller =&gt; "user"
    get "/user" =&gt; "user#index"
    get "/sign_up" =&gt; "user#new"
    get "/sign_in" =&gt; "user#sign_in"
    get "/sign_out" =&gt; "user#sign_out"
    post "/authenticate" =&gt; "user#authenticate"
    resources :articles
    resources :article_categories
  end
  </code></pre>
  
  <p>...it works!</p>
  
  <p>But index action is not defined in user controller! 
  'rake routes' command returns double line for GET /user</p>
  
  <pre><code>          GET    /user(.:format)          frontend/user#show
            GET    /user(.:format)          frontend/user#index
  </code></pre>
  
  <p>so I suppose that's not the solution. Other actions assigned to '/users' URL don't work.</p>
  
  <p>Is it necessary to define the route for the index action like</p>
  
  <pre><code>get "/controller_name" =&gt; "controller_name#index"
  </code></pre>
  
  <p>What am I doing wrong?</p>