我正在使用以下内容来尝试在表单上设置一个PUT方法,但它仍然在做一个帖子.我已经提到了这个文件,而且似乎这样做是正确的.
form_for @firm,html: {autocomplete: "off"},url: firm_path,method: :put do |f| ...
解决方法
这样做是因为浏览器不支持PUT / DELETE.您可以在
Rails Guides中阅读更多信息:
However,most browsers don’t support methods other than “GET” and
“POST” when it comes to submitting forms.Rails works around this issue by emulating other methods over POST
with a hidden input named"_method"
,which is set to reflect the desired method.