0

I'm reading through Hartl's book, Ruby on Rails by Example. In chapter 11, it has you implement delete requests to allow users to delete microposts on their profile. However when I click the delete button, I receive this routing error: No route matches [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.

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

Routing Error No route matches [GET] "/microposts/304 - Deleting a Micropost - Michael Hartl's railstutorial.org Chapter 11

'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's-ruby-on-rails-tutorial---completely-stumped.

Community
  • 1
  • 1
Dmat00
  • 417
  • 2
  • 5
  • 8
  • The questions you link to all have more-or-less the same answer... this does not help you?? – Mischa Dec 15 '11 at 07:53

2 Answers2

0

You should add :method => :delete to trigger delete action. 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. If this is not help you show us your routes and view.

Mikhail Nikalyukin
  • 11,867
  • 1
  • 46
  • 70
0

It's a Rails 3.1 issue. Look at your page header -- instead of jquery, it's trying to load "defaults.js," which doesn't exist.

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

mockturtl
  • 82
  • 4
  • That is exactly it. Easy fix. Thanks for the help. – Dmat00 Dec 15 '11 at 19:22
  • Do you know why this line would be needed? <%= stylesheet_link_tag "application" %> It doesn't have you delete the original style sheet link? Jquery seems to be working smoothly without this in? I only ask because this additional style sheet ruins the page. – Dmat00 Dec 15 '11 at 19:22