ruby-on-rails – Rails link_to方法:: delete
我很抱歉问什么可能是一个补救问题,但在学习rails时我试图按照本教程中的注释说明:
http://guides.rubyonrails.org/getting_started.html 我昨晚在本教程中发布了一个类似的问题并得到了一个迅速响应,这对我帮助很大,所以我希望同样如此.先感谢您. 第5.14节:删除帖子 我被指示向index.html.erb页面添加删除链接 <h1>Listing Posts</h1> <table> <tr> <th>Title</th> <th>Text</th> <th></th> <th></th> <th></th> </tr> <% @posts.each do |post| %> <tr> <td><%= post.title %></td> <td><%= post.text %></td> <td><%= link_to 'Show',post_path %></td> <td><%= link_to 'Edit',edit_post_path(post) %></td> <td><%= link_to 'Destroy',post_path(post),method: :delete,data: { confirm: 'Are you sure?' } %></td> </tr> <% end %> </table> 产生: <td><a data-confirm="Are you sure?" data-method="delete" href="/posts/1" rel="nofollow">Destroy</a></td> 对我来说看起来不错,但是当我点击链接时,我既没有得到确认,也没有指向删除操作.它会生成此HTTP操作 Request URL:http://localhost:3000/posts/1 Request Method:GET Status Code:200 OK Rails:4,Ruby:2,64位windows 8,chrome:版本28.0.1500.72 m 再次感谢你 添加application.html.erb <!DOCTYPE html> <html> <head> <title>Listing</title> <%= stylesheet_link_tag "application",media: "all","data-turbolinks-track" => true %> <%= javascript_include_tag :application %> <%= csrf_meta_tags %> </head> <body> <%= yield %> </body> </html> 产生了这个错误:
的application.js //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . 解决方法
确保你有
//= require jquery //= require jquery_ujs 到application.js文件和application.js文件包含在view / layout / application.html.erbfile中 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |