views:

29

answers:

3

I've put this line in my routes.db file:

map.mything '/mything', :controller => 'mything', :action => 'list'

But I get this error when I go to http://localhost:3000/mything, I get this error:

Unknown action
No action responded to index. Actions: list

Why is it trying to use index instead of list? I thought that by setting

:action => 'list'

it would use the list action? Thanks for reading.

A: 

Sorry for asking a potentially obvious question, but have you tried restarting the app? Certain routes will not register until you restart the application (RESTful resources never need an application restart, but others often do).

adriandz
Hadn't tried that, just did and still got the error.
ben
+1  A: 

Agreeing with Jim Schubert, put the named routes above the default routes.

Another likely problem is that you have something like:

map.resources :mything

which is setting an index action on the controller as a result of you scaffolding a model

Jamie Wong
+1  A: 

You have to put named routes above the default routes.

I put named routes like these at the top of routes.rb so they always get evaluated first.

ActionController::Routing::Routes.draw do |map| 
  map.about 'about', :controller => 'home', :action => 'about'
  map.contact 'contact', :controller => 'home', :action => 'contact'

  # MORE CONFIG

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end
Jim Schubert