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?
2
Answers
It seems to me that you could take out show and then define the route that you want separately. See if this works:
EDIT: Ah, yes. The :as parameter needs a different name. This will work:
A good way to eliminate routes unneeded is by specifying the :only option
instead of