Routing a restful controller to work from site root

hi i have rewritten my map.resources so that a resource is called from
the start: map.connect ‘’, :controller => “resource”

so www.mysite.com lists the available resource

however i want www.mysite.com/1 to show one of a particular resource
rather than www.mysite.com/show/1 as is the default restful route.

how can i get this url?

thanks

this is great but what about with nested resources?

thanks

On Jul 6, 9:19 pm, Michael M. [email protected]

Marc Rice wrote:

hi i have rewritten my map.resources so that a resource is called from
the start: map.connect ‘’, :controller => “resource”

so www.mysite.com lists the available resource

however i want www.mysite.com/1 to show one of a particular resource
rather than www.mysite.com/show/1 as is the default restful route.

how can i get this url?

map.connect ‘:id’, :controller => “resources”, :action=>“show”

A few things in you post don’t make sense to me…

  1. You say that www.mysite.com/show/1 is a “RESTful route,” but it’s
    not. RESTful routes don’t include the action (show) in this case.
    Say if your resource/model was Post then the RESTful URL would look
    something like www.mysite.com/posts/1. Notice there’s no mention of
    the action. The action is based on the HTTP verb used to access the
    URL. Show would be a GET request, POST to create, PUT to update,
    DELETE to destroy.

  2. If you are using RESTful routes you would use map.resources not
    map.connect to declare your resources, which in turn creates the
    RESTful URLs.

  3. If what you really mean is that you want to drop the resource out
    of the URL, which I must assume your application has only one main
    resource and everything else in the database is nested, then you would
    need to use map.connect or a named route to do that.