-2

以下是我得到的错误,当我尝试添加一个名为 decrement 的按钮并实现它时

No route matches {:controller=>"line_items", :product_id=>#<Product id: 2, title: "Harry Potter", description: "Its drama cum adventure cum suspense cum thriller, ...", image_url: "harry-potter_25.png", price: #<BigDecimal:b068140,'0.1E3',4(8)>, created_at: "2013-03-15 07:21:26", updated_at: "2013-03-18 11:57:13">, :action=>"decrement"}    
4

2 回答 2

0

在按钮的路径中替换:product_id => product:product_id => product.id

<%= button_to 'Remove from cart', decrement_line_items_path(:product_id => product.id), :method => :put, :remote => true %>
于 2013-03-22T08:38:47.570 回答
0

如果您将 button_to 的实现代码与错误一起粘贴,将会有所帮助。

此外,您似乎在 button_to 中传递了整个产品对象来针对 product_id 调用

#<Product id: 2, title: "Harry                 Potter", description: "Its drama cum adventure cum suspense cum thriller, ...", image_url:        "harry-potter_25.png", price: #<BigDecimal:b068140,'0.1E3',4(8)>

而是只尝试 product.id

于 2013-03-22T06:59:08.397 回答