Url routing issue - Agile Rails Chapter 6

I am walking through the tutorial in Agile web development with rails book 3rd edition.

When I try to access the url http://localhost:3000/products I get this error

No route matches "/products" with {:method=>:get}

Which - when I look at the products controller I do not understand how the url in the book is correct?

In the previous chapter I created a Say controller which had a hello action. But, the products controller has index, show, new, edit, create, update and destroy.

I tried /products/new and products/index and still nothing...

What am I missing here?

The 'No route matches...' error usually suggests that something is missing in your config/routes.rb file. At this point in the tutorial, you should have:

map.resources :products

somewhere in your config/routes.rb. Do you?

( This is a bit hard to diagnose, as you've noticed, because the 'resource'-style routing adds some standard mappings that aren't like the explicit /controller/action mapping you were previously introduced to. In this case, behind the scenes, the 'map.resources :products' adds a route that maps /products to ProductsController#index. You can read more about this in the Rails Routing guide [1]. It seems weird and magical at first, but it'll soon become second nature, trust me! )

Chris

[1] http://guides.rubyonrails.org/routing.html#restful-routing-the-rails-default

Use

rake routes

from any directory in your Rails app to list your routes. I’ve found it a big help, especially for understanding what’s going on behind the scenes.

Fred

Thanks for the responses but, I found the issue.

I am really new to this (obviously) but, I think I had started Webrcik in my demo directory and not the depot on which it should have been.

Another thing is that I found this website.

That shows using script/generate without a '/' in the command. The book uses this and it was causing an issue trying to run db:migrate. My migration file had a space between the ':' colon and the column name.

Once I fixed those things I can now get to the url just fine.

Trying to figure out the differences is a pain. The book says it is for Rails 2 and I am running Rails 2.3.8 you'd think this would be a no-brainer.