【发布时间】:2017-07-04 18:14:36
【问题描述】:
我有两个链接(如果需要,可以是按钮)表示接受和拒绝,我需要通过单击其中一个链接将真或假参数发送到我的控制器操作。我不希望我的参数在 url 中可见,所以我需要使用 put 方法。我已经尝试使用带有定义方法的 link_to:
<%= link_to 'accept', { action: 'accept_offer', accept: true }, method: :put %>
<%= link_to 'decline', { action: 'accept_offer', accept: false }, method: :put %>
但我的参数仍然可见。
我尝试过使用 button_to 但我的参数没有通过。 确定选择了哪个选项(接受或拒绝)而不在 url 中显示参数的最佳方法是什么?
我的路线是这样定义的:
put 'offers', to: 'offers#accept_offer'
【问题讨论】:
标签: ruby-on-rails parameter-passing put link-to button-to