Forum: Ruby on Rails retrieve resource name from request

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Borja Martín (Guest)
on 2008-11-26 01:21
(Received via mailing list)
I was wondering if there is any way for retrieving the resource name
from the request.
Suppose I have the following resource definition in my routes.rb file:

map.resources :pages, :controller => 'documents'

now, when the url /pages/ is requested with the GET method, the method
'index' in the DocumentsController will be called and the resource name
I would like to retrieve is :pages

I know I could probably do this from the URI, but in case the :as option
is used it wouldn't work anymore:

map.resources :pages, :controller => 'documents', :as => 'foo'

Now, when the url /foo/ is called, the method index in the
DocumentsController will be also called but the resource name should
still be :pages

Any hint?

I looked at the ActionController::Routes classes but didn't find
anything useful...

Thanks in advance

 * dagi3d v4 -
This topic is locked and can not be replied to.