How To Create A Custom Route Inside Resource Without Overwrite Path

- 1 answer

I’ve this on routes.rb

resources :questions, except: [:show] do
   get '/resource/:subject/:id', to: 'resource#show', as: "resource", param: [:name, :id]

It says that:

Invalid route name, already in use: ‘resource' You may have defined two routes with the same name using the :as option, or you may be overriding a route already defined by a resource with the same naming

I know that resources create two routes with the same path, show and destroy both uses resource_path, how does it is being created internally? and how i can generate my route for show wihtout overwrite the one in destroy?



A good way to eliminate routes unneeded is by specifying the :only option

resources :user, :only => [:edit] 

instead of

resources :user, :except => [:new, :create, :edit, :update, :show, :destroy]