[英]Making rails button_to link to a path with a parameter
I am trying to set up a button that goes to a path but I cannot figure out what to set the path to. 我正在尝试设置一个去往路径的按钮,但我无法弄清楚要设置路径的方法。 Currently I have it set up like this:
目前我的设置如下:
= button_to "buy" , product_card_path, :method => "get"
but I get an error. 但是我收到了一个错误。
No route matches {:action=>"card", :controller=>"products"}
This is the path in the rake routes: 这是rake路线中的路径:
product_card GET /products/:product_id/card(.:format) products#card
How do I make a button_to go to a path that requires a parameter? 如何使button_to转到需要参数的路径?
Try: 尝试:
= button_to "buy" , product_card_path(your_product_instance), method: :get
Not sure whether or not the method: :get
is necessary here. 不确定
method: :get
是否method: :get
是必要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.