我正在使用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 %>
Run Code Online (Sandbox Code Playgroud)
我的路线文件包含以下内容:
resources :posts
Run Code Online (Sandbox Code Playgroud)