相关疑难解决方法(0)

删除链接在Rails 3视图中发送"Get"而不是"Delete"

我正在使用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)

ruby-on-rails ruby-on-rails-3

39
推荐指数
3
解决办法
1万
查看次数

标签 统计

ruby-on-rails ×1

ruby-on-rails-3 ×1