ruby-on-rails – PUT方法form_for

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – PUT方法form_for前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用以下内容来尝试在表单上设置一个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.

原文链接:https://www.f2er.com/ruby/273808.html

猜你在找的Ruby相关文章