views:

51

answers:

2

I've created a DB and a table within that DB called genre.

Now when I try to connect to this using the URL, I get the following error message:

Routing Error

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

Thanks for your help in advance.

+2  A: 

As @Jens Fahnenbruck said, you need to set up your route in config/routes.rb.

If you want to find out what routes exist on your app, type rake routes into the command line.

Jeriko
+1 for rake routes
DJTripleThreat
About the Map Routes, I have no : map.resources :genres line in the code, is this required?I have everything else.
WANNABE
the map.connect lines in my example would catch your /genres routes but you really need to have map.resources :genres in there so you can make use of the genres path variables like `link_to new_genre`
DJTripleThreat
check your routes with `rake routes`. If /genres isn't there, you need to adjust your `routes.rb` file - yes, you probably need to add `map.resources :genres`, but there are several ways of achieving what you want. Check out the top few screencasts in this search: http://railscasts.com/episodes?search=route
Jeriko
+3  A: 

I think that /genre should be /genres

I just wrote an app from scratch to work with genres and this is my routes file:

ActionController::Routing::Routes.draw do |map|
  map.resources :genres

  # these last two lines should go away but I left them in
  # here because my example worked as is.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

So you would want to make sure that you are using the pural form of the noun genre.

Also rake routes is a great way to see what your routes are setup as.

DJTripleThreat
Brilliant thanks mate.
WANNABE
you're welcome!
DJTripleThreat
Beware `connect ':controller/:action/:id'`, it makes all your controller methods accessible via `GET` requests - `resources` for restful routes is all you really need there ^.^
Jeriko
Yes good point! I left them in my example because the example worked in that state. WANNABE, you'll want to remove those entries before you go to production.
DJTripleThreat
At last its doing something but now I'll getting this error - DOH! I've looked it up across the web and it seems to be a problem with an empty index.html.erb file?NameError in GenresController#indexuninitialized constant GenresControllerRAILS_ROOT: C:/Users/Will/Desktop/INSTAN~1/rails_apps/talewiki
WANNABE
WANNABE, if you post your email here, I will send you the code that I used to get this to work.
DJTripleThreat