简体   繁体   中英

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

I would like to see if as: http://localhost:3000/feed_products/34

How do I do this in Ruby on Rails?

Thanks!

Replace the path in above link to with

 feed_product_path(product)

feed_products_path is for the index action. 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.

I hope you are not trying to pass an object there. Let me know if this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM