gpt4 book ai didi

ruby-on-rails - rails :method=>:patch doesn't work

转载 作者:行者123 更新时间:2023-12-03 12:19:14 29 4
gpt4 key购买 nike

所以,我有这个表格声明:

<%= form_for 'students_list', {:url => update_students_list_stream_url(@stream), :method=>:patch}  do |students_list_form| %>

正如 API 文档中所述,但这导致我出错:
No route matches [POST] "/streams/26/edit-students-list"

所以它仍然尝试发布,即使我的 HTML 输入有:
<input type="hidden" name="_method" value="patch" />

从 Rails 指南:

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:



我很困惑

最佳答案

我正在寻找有关为什么 rails 将方法补丁加载为渲染形式中的帖子的答案。
如果你最终像我一样在这里寻找那个,这就是你正在寻找的答案:

https://stackoverflow.com/a/46699512/5750078

来自 https://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark :

enter image description here

关于ruby-on-rails - rails :method=>:patch doesn't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34246383/

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