加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – PUT方法form_for

发布时间:2020-12-16 20:38:09 所属栏目:百科 来源:网络整理
导读:我正在使用以下内容来尝试在表单上设置一个PUT方法,但它仍然在做一个帖子.我已经提到了这个文件,而且似乎这样做是正确的. form_for @firm,html: {autocomplete: "off"},url: firm_path,method: :put do |f|... 解决方法 这样做是因为浏览器不支持PUT / DELET
我正在使用以下内容来尝试在表单上设置一个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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读