I cannot figure out why I am getting this error. I know this question is very similar to this question, but I have all the jquery links correct as verified by the fact that I can delete users without a problem but not the microposts. When I try the example in the browser and click the delete link(http://localhost:3000/microposts/253) on a micropost, even though the item does get deleted the browser says:
Routing Error
No route matches [GET] "/microposts/253"
Try running rake routes for more information on available routes.
Test result:
Micropost pages micropost destruction as correct user should delete a micropost
Failure/Error: expect { click_link "delete" }.should change(Micropost, :count).by(-1)
ActionController::RoutingError:
No route matches [GET] "/microposts/1"
routes.rb
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', via: :delete
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#contact'
root to: 'static_pages#home'...
Microposts delete link:
<%= link_to "delete", micropost, method: :delete,
confirm: "You sure?",
title: micropost.content %>
Microposts controller:
class MicropostsController < ApplicationController
before_filter :signed_in_user, only: [:create, :destroy]
before_filter :correct_user, only: :destroy
def create
@micropost = current_user.microposts.build(params[:micropost])
if @micropost.save
flash[:success] = "Micropost created!"
redirect_to root_path
else
@feed_items = []
render 'static_pages/home'
end
end
def destroy
@micropost.destroy
redirect_back_or root_path
end
private
def correct_user
@micropost = current_user.microposts.find_by_id(params[:id])
redirect_to root_path if @micropost.nil?
end
end
I am unable to find the 3.2 tutorial repo to compare my sample_app to but I think I've followed the tutorial to the letter. Any help is appreciated.