我使用的是Rails 3,有一个页面可以输出数据库中的帖子列表.我希望能够从链接中删除帖子.
下面的第二个例子行得通,但第一个不行.有人知道第一个为什么行不通吗?我的观点包括:
# 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