gpt4 book ai didi

ruby-on-rails - PUT 方法 form_for

转载 作者:行者123 更新时间:2023-12-03 03:05:37 25 4
gpt4 key购买 nike

我正在使用以下方法尝试在表单上设置 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.

关于ruby-on-rails - PUT 方法 form_for,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9551330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com