简体   繁体   中英

Rails params not receiving variable passed from view

I have defined a CRUD resource called items , which I've added a collection route to called similar_items .

In the view/show , I have: link_to similar_items_items_path(), :similar_to => @item

In my similar_items controller method, what's the best way to get the item that was passed from link_to ? The params hash does not contain similar_to which I've clearly passed as shown above. Why is it not being passed into params?

您应该在路径助手中传递参数:

link_to 'Your link label here', similar_items_items_path(:similar_to => @item)

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