在Rails中从提交按钮禁用URL参数?

时间:2013-04-17 02:25:50

标签: ruby-on-rails forms url-parameters

点击该按钮会在网址中传递button=

# example.html.haml
= form_for @contact, html: { method: :get }
  = f.text_field :phone
  = f.button "Call Me!"

如何阻止Rails传递额外的URL参数?

1 个答案:

答案 0 :(得分:2)

name: nil添加到按钮:

= form_for @contact, html: { method: :get }
  = f.text_field :phone
  = f.button "Call Me!", name: nil

来源:How to disable submit button parameter in Rails