Ruby on rails Rails 3嵌套资源路由错误

Ruby on rails Rails 3嵌套资源路由错误,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,在用户创建新的“服务”资源后,我无法将其重定向到我想要的页面 以下是routes.rb: resources :wsps do resources :services end html表单: <%= form_for([@wsp,@service]) do |f| %> wsp_service_路径指向/wsps/1/services,错误为: No route matches {:action=>"destroy", :controller=>"servic

在用户创建新的“服务”资源后,我无法将其重定向到我想要的页面

以下是routes.rb:

resources :wsps do
    resources :services
end
html表单:

<%= form_for([@wsp,@service]) do |f| %>
wsp_service_路径指向/wsps/1/services,错误为:

No route matches {:action=>"destroy", :controller=>"services"}
我做错了什么?为什么我不能使用“wsp\U服务\U路径”


谢谢。

您可以使用
wsp\u service\u path
(因为您在控制器中,所以应该使用
wsp\u service\u url
)。你所缺少的只是论点
wsp\u service\u path
(或
\u url
)需要两个参数:wsp和服务。一旦你提供了这两个,它就会起作用

redirect_to wsp_service_url(@wsp, @service) 
redirect_to wsp_service_url(@wsp, @service)