我有一些单一的嵌套资源,它们的条目如下所示:
resources :rocs, only: [:show] do
resource :r1_response, :r2_response, :r3_response, :r4_response :r5_response do
member do
get :print
end
end
end
现在我想为我的嵌套奇异资源动态生成路径,如下所示:
print_roc_r1_response_path
print_roc_r2_response_path
...
我正在尝试使用polymorphic_path
生成以上路径:
link_to "Print ROC", polymorphic_path([:print, @roc, controller.controller_name])
但是它给出了错误:undefined method print_roc_r1_responses_path
因为controller.controller_name
是复数。我该如何解决?
答案 0 :(得分:0)
resources :rocs, only: [:show] do
resources :r1_response, :r2_response, :r3_response, :r4_response :r5_response do
member do
get :print
end
end
end
将资源更改为资源