[英]Ruby on Rails add path in link_to?
I have this: 我有这个:
<li><%= link_to "More", feed_products_path(product.id) ,{:class=>"button-small white"} %></li>
This link outputs: http://localhost:3000/feed_products.34 该链接输出: http:// localhost:3000 / feed_products.34
I would like to see if as: http://localhost:3000/feed_products/34 我想看看是否为: http:// localhost:3000 / feed_products / 34
How do I do this in Ruby on Rails? 如何在Ruby on Rails中做到这一点?
Thanks! 谢谢!
Replace the path in above link to with 将上面链接中的路径替换为
feed_product_path(product)
feed_products_path is for the index action. feed_products_path用于索引操作。 If you pass an object to it then it appears as format("format" => "1"), 1 being the id of the object passed, in the params hash. 如果将对象传递给它,则它在params哈希中显示为format(“ format” =>“ 1”),1是传递的对象的ID。
I hope you are not trying to pass an object there. 希望您不要在此处传递对象。 Let me know if this helps. 让我知道是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.