# Retrieve resource name from request

**URL:** <https://www.ruby-forum.com/t/retrieve-resource-name-from-request/154162>\
**Category:** Rails\
**Created:** [November 26, 2008, 12:21am UTC](https://www.ruby-forum.com/t/retrieve-resource-name-from-request/154162 "2008-11-26T00:21:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Borja\_MartSSS\_n](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f08c70/32.png) [@Borja\_MartSSS\_n](https://www.ruby-forum.com/u/Borja_MartSSS_n)\
**Post date:** [November 26, 2008, 12:21am UTC](https://www.ruby-forum.com/t/retrieve-resource-name-from-request/154162/1 "2008-11-26T00:21:15Z")

</div>

Hi,  
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 - [http://dagi3d.net](http://dagi3d.net)  
\*/
