form_tag url_for 带有:方法“删除”、id 和:remote =>真的

发布于 2024-12-19 18:59:40 字数 661 浏览 3 评论 0 原文

我有以下 form_tag 工作:

<%= form_tag url_for(:controller => "profiles", :action => "remove_academic", :method => :delete), :id => "remove_major_goal", :remote => true do %>

但是,生成的 HTML 显示:method => “删除”不起作用。所以我在 答案 >form_tag 并尝试了这个:

<%= form_tag url_for({ :controller => "profiles", :action => "remove_academic", :method => "delete" }, { :id => "remove_major_goal", :remote => true }) do %>

但是这会引发错误。我做错了什么?

I have the following form_tag working:

<%= form_tag url_for(:controller => "profiles", :action => "remove_academic", :method => :delete), :id => "remove_major_goal", :remote => true do %>

However, the HTML produced shows that :method => "delete" isn't working. So I found a few answers here on form_tag and tried this:

<%= form_tag url_for({ :controller => "profiles", :action => "remove_academic", :method => "delete" }, { :id => "remove_major_goal", :remote => true }) do %>

However that kicks back an error. What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

两人的回忆 2024-12-26 18:59:40

DELETE 不是 HTML 表单元素的 method 属性的有效值。您可能最好在表单内插入 (或使用辅助方法来执行此操作)。

更新:

尝试其中之一:

form_for url_for(:controller => "", :action => ""), :method => "delete", …

form_for { :controller => "", :action => "" }, { :method => "delete", … }

第二种形式中的第二组大括号可能是不必要的。同样,第一种形式可能需要它们。

DELETE is not a valid value of the method attribute for a HTML form element. You would probably be better inserting a <input type="hidden" name="method" value="delete" /> inside the form (or use a helper method to do so).

Update:

Try one of these:

form_for url_for(:controller => "", :action => ""), :method => "delete", …

form_for { :controller => "", :action => "" }, { :method => "delete", … }

The second set of braces in the second form maybe unnecessary. Likewise, they might be needed in the first form.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文