我正在使用Rails 3并且有一个输出数据库中的帖子列表的页面。我希望能够从链接中删除帖子。删除链接在Rails 3视图中发送“Get”而不是“Delete”
下面的第二个例子工作,但第一个例子没有。任何人都知道为什么第一个不行?我的观点包括:
# this link sends a "GET" request which asks for the #show function
<%= link_to 'Delete', post, :method => :delete %>
# this link sends the proper "DELETE" request which asks for the #destroy function
<%= button_to 'Delete', post, :method => :delete %>
我的路由文件包含以下内容:
resources :posts
伟大的答案。谢谢。 – 2010-09-23 03:37:08
这对我有很大的帮助。 – Rupert 2011-01-04 06:59:13
谢谢 - 你能发布一个链接,了解rails 3的这个特性的细节吗? – gorn 2011-04-21 01:18:15