views:

766

answers:

1

I'm following the guide at, http://guides.rubyonrails.org/getting_started.html

Ruby 1.9.2p0
Rails 3.0.0

But I'm locked at 6.2/6.3, when I try to add the;

<%= link_to "Species", species_path %>

I get the error (I switched the Post example to Specie);

ActionController::RoutingError in Home#index No route matches {:action=>"destroy", :controller=>"species"}

Terminal history:

bundle install
rake db:create
rails generate controller home index
rm public/index.html
rails generate scaffold Specie name:string latin:string
rake db:migrate

The path localhost:3000/species/ works but not localhost:3000/species/new

Rake routes:

species_index GET /species(.:format) {:action=>"index", :controller=>"species"}
species_index POST /species(.:format) {:action=>"create", :controller=>"species"}
new_species GET /species/new(.:format) {:action=>"new", :controller=>"species"}
edit_species GET /species/:id/edit(.:format) {:action=>"edit", :controller=>"species"}
species GET /species/:id(.:format) {:action=>"show", :controller=>"species"}
species PUT /species/:id(.:format) {:action=>"update", :controller=>"species"}
species DELETE /species/:id(.:format) {:action=>"destroy", :controller=>"species"}
home_index GET /home/index(.:format) {:controller=>"home", :action=>"index"}
root /(.:format) {:controller=>"home", :action=>"index"}

routes.rb

resources :species
get "home/index"
root :to => "home#index"

+1  A: 

Your problem is that the plural of species is species (they are the same).

The answer is in your rake routes. Note you'll want to use:

<%= link_to "All Species", species_index_path %>

See Section 4.8 - Overriding The Singular Form in the Routing guide for more info.

macek
Thanks for taking your time, really appreciated.
Olle