Ruby on rails 为什么不是';我的链接是否与正确的操作关联?
我有以下链接:Ruby on rails 为什么不是';我的链接是否与正确的操作关联?,ruby-on-rails,Ruby On Rails,我有以下链接: <%= link_to 'Delete', store_product_path(@store, @product), :method => 'delete', :confirm => 'This cannot be undone. Are you sure?', :class => 'btn' %> 所以,我不确定链接出了什么问题。有没有更详细的方法来编写链接,可能对我有用?谢谢当前,您在“商店”中没有嵌套的资源“产品”。根据rake路线, 您
<%= link_to 'Delete', store_product_path(@store, @product), :method => 'delete', :confirm => 'This cannot be undone. Are you sure?', :class => 'btn' %>
所以,我不确定链接出了什么问题。有没有更详细的方法来编写链接,可能对我有用?谢谢当前,您在“商店”中没有嵌套的资源“产品”。根据rake路线, 您已将产品的路线定义为
资源:产品
所以,你的链接应该是
<%= link_to 'Delete', product_path(@product), :method => 'delete', :confirm => 'This cannot be undone. Are you sure?', :class => 'btn' %>
您当前的链接将按原样工作无需更改任何内容,只要路由是按照上述建议定义的当前,“存储”中没有嵌套的资源“产品”。根据rake路线, 您已将产品的路线定义为
资源:产品
所以,你的链接应该是
<%= link_to 'Delete', product_path(@product), :method => 'delete', :confirm => 'This cannot be undone. Are you sure?', :class => 'btn' %>
您当前的链接将按原样工作无需更改任何内容,只要按照上述建议定义路线我的回答解决了您的问题吗?我也回答了你的另一个问题。请尝试解决方案并让我知道。我的回答是否解决了您的问题?我也回答了你的另一个问题。请尝试解决方案并让我知道。
<%= link_to 'Delete', product_path(@product), :method => 'delete', :confirm => 'This cannot be undone. Are you sure?', :class => 'btn' %>
resources :stores do
resources :products
end