添加新按钮时发生路由错误

时间:2013-03-22 06:54:55

标签: ruby-on-rails

当我尝试添加名为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"}    

2 个答案:

答案 0 :(得分:0)

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

此外,您似乎在针对product_id

的button_to调用中传递了整个产品对象
#<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

答案 1 :(得分:0)

将<{1}}替换为按钮路径中的:product_id => product

:product_id => product.id