简体   繁体   English

Micropost-路由错误没有路由匹配[GET]-删除Micropost

[英]Micropost - Routing Error No route matches [GET] - Deleting a Micropost

I'm reading through Hartl's book, Ruby on Rails by Example. 我正在阅读Hartl的《 Ruby on Rails示例》一书。 In chapter 11, it has you implement delete requests to allow users to delete microposts on their profile. 在第11章中,您实现了删除请求,以允许用户删除其个人资料上的微博。 However when I click the delete button, I receive this routing error: No route matches [GET] /microposts/303" 但是,当我单击删除按钮时,我收到此路由错误:没有路由与[GET] / microposts / 303相匹配

I've found similar posts with other people who have had the same problem. 我发现其他遇到相同问题的人也有类似的帖子。 But no one seems to have figured out a clear way to resolve this issue. 但是似乎没有人找到解决此问题的明确方法。 Maybe it is just too late at night but I am stumped. 也许到了晚上还为时已晚,但我很沮丧。 I know it has something to do with the js file or jquery. 我知道这与js文件或jquery有关。

Can you please help? 你能帮忙吗?

Here are the other posts detailing the same problem: 这是其他详述相同问题的文章:

jQuery not working at delete action on Michael Hartl's tutorial, chapter 11 jQuery在Michael Hartl教程的第11章中无法执行删除操作

Routing Error No route matches [GET] "/microposts/304 - Deleting a Micropost - Michael Hartl's railstutorial.org Chapter 11 路由错误没有路由匹配[GET]“ / microposts / 304-删除微博-迈克尔·哈特(Michael Hartl)的railstutorial.org第11章

'No route matches' Error on Delete of Micropost in Chapter 11 of Hartl's ruby-on-rails tutorial - completely stumped Hartl的ruby-on-rails教程第11章中的“删除微博”中的“没有路线匹配”错误-完全被卡住

http://www.techques.com/question/1-5871875/'No-route-matches'-Error-on-Delete-of-Micropost-in-Chapter-11-of-Hartl's-ruby-on-rails-tutorial---completely-stumped. http://www.techques.com/question/1-5871875/“No-route-matches”-Error-on-Delete-of-Micropost-in-Chapter-11-of-Hartl的-ruby-on-rails-教程---完全绊脚了。

You should add :method => :delete to trigger delete action. 您应该添加:method => :delete来触发删除操作。 If you have this code in your view and its not working, than my guess is that you either don't have the necessary javascript files in your project (jquery.js and rails.js/jquery_ujs.js) or you are not including them in your layout. 如果您认为此代码不起作用,那么我猜测您的项目中没有必要的javascript文件(jquery.js和rails.js / jquery_ujs.js),或者您不包括它们在您的布局中。 If this is not help you show us your routes and view. 如果这样做没有帮助,请向我们显示您的路线和视图。

It's a Rails 3.1 issue. 这是一个Rails 3.1问题。 Look at your page header -- instead of jquery, it's trying to load "defaults.js," which doesn't exist. 查看您的页面标题-而不是jquery,它正在尝试加载不存在的“ defaults.js”。

http://ruby.railstutorial.org/chapters/rails-3-1#code:layout_rails_3_1_diff http://ruby.railstutorial.org/chapters/rails-3-1#code:layout_rails_3_1_diff

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM