I'm working on rails tutorial by Michael Hartl like other newbies in rails do. anyway, I'm stuck at the chapter 11 like those too with some JQuery not working with delete action issue. That's to say, when clicking on any delete button, it only redirects me to a particular error page saying "No route matches [GET] "/microposts/301"
My code in the _micropost.html.erb page is as below:
<tr>
<td class="micropost">
<span class="content"><%= micropost.content %></span>
<span class="timestamp">
Posted <%= time_ago_in_words(micropost.created_at) %> ago.
</span>
</td>
<% if current_user?(micropost.user) %>
<td>
<%= link_to "delete", micropost, :method => :delete,
:confirm => "You sure?",
:title => micropost.content %>
</td>
<% end %>
</tr>
So, I checked with my gem file whether it had prototype and jQuery conflict or not. what I found is as below
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
#gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'rspec-rails', '2.6.1'
gem 'faker', '0.3.1'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
gem 'factory_girl_rails', '1.0'
end
group :production do
gem 'therubyracer-heroku', '~> 0.8.1.pre3', :platform => :ruby
#gem 'therubyracer-heroku', '0.8.1.pre3' # you will need this too
gem 'pg'
end
So, I am quite so sure here there is no prototype installed, as I heard for the rails 3.1 onward the jQuery is used by default.
Any advice that you think to get it working for me? Where to check that my jQuery is already installed properly.
As per @Tuck's suggestion, I post my routes.rb here.
SampleApp::Application.routes.draw do
resources :users
resources :sessions, :only => [:new, :create, :destroy]
resources :microposts, :only => [:create, :destroy]
match '/signup', :to => 'users#new'
match '/signin', :to => 'sessions#new'
match '/signout', :to => 'sessions#destroy'
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
root :to => 'pages#home'
get "pages/home"
get "pages/contact"
get "pages/about"
end