0
在我的路線嵌套routes文件指向錯誤的路線
resources :shops do
resources :products
end
我有一個產品上市,如
<% @products.each do |p| %>
<div class="item">
<p class="text-center"><%= link_to p.name, shop_product_path(p) %></p>
<p class="text-center"><strike>Rs.250</strike> <strong>Rs.<%= p.price %></strong></p>
<center><%= link_to "Order now", new_product_order_path(p), :class => "btn btn-primary" %></center>
</div>
<% end %>
但這裏有個鏈接
<p class="text-center"><%= link_to p.name, shop_product_path(p) %></p>
它指向
http://localhost:5000/shops/6/products/1
但這應該是像
http://localhost:5000/shops/1/products/6
什麼是這裏的錯誤呢?
什麼是'p.id'和'p.shop_id'? –
產品ID是6,商店ID是1 –
我認爲你需要將兩個ID都傳遞給路由幫助器 –