When using the controller name in the singular, the route is prefixed with _index
to the end of the route name (eg dispute_conference_index
). Within the controller in method create
the parameter location
in render
receives the URL of the registry.
Unfortunately the name passed to location
is dispute_conference_url
instead of dispute_conference_index
.
See below the route setting I'm using:
resources :disputes, shallow: true do
scope module: :dispute do
resources :conference, except: :index
end
end
See the details of routes:
Prefix Verb URI Pattern Controller#Action
conferences GET /conferences(.:format) conferences#index {:format=>:json}
dispute_conference_index POST /disputes/:dispute_id/conference(.:format) dispute/conference#create {:format=>:json}
conference GET /conference/:id(.:format) dispute/conference#show {:format=>:json}
PATCH /conference/:id(.:format) dispute/conference#update {:format=>:json}
PUT /conference/:id(.:format) dispute/conference#update {:format=>:json}
DELETE /conference/:id(.:format) dispute/conference#destroy {:format=>:json}
PUT /conference/:id/start(.:format) dispute/conference#start {:format=>:json}
PUT /conference/:id/cancel(.:format) dispute/conference#cancel {:format=>:json}
PUT /conference/:id/finish(.:format) dispute/conference#finish {:format=>:json}
What is the correct way to fix this question, passing location
correct?
Correcting the question : The reason for the error is because of the shallow: true
parameter, it changes the path
of the routes, causing a manual intervention or through a function (url_path ).
When trying to run the create
method, an error will be obtained because location
can not be found.