# Nested resource routing

**URL:** <https://www.ruby-forum.com/t/nested-resource-routing/130563>\
**Category:** Rails\
**Created:** [February 29, 2008, 12:06pm UTC](https://www.ruby-forum.com/t/nested-resource-routing/130563 "2008-02-29T12:06:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![liseki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7ab992/32.png) [@liseki](https://www.ruby-forum.com/u/liseki)\
**Post date:** [February 29, 2008, 12:06pm UTC](https://www.ruby-forum.com/t/nested-resource-routing/130563/1 "2008-02-29T12:06:32Z")

</div>

I am using rails 1.2.6 and I’m trying to define a RESTified route that  
will work for a nested resource. I have a permission resource that I  
want to be nested into all my other resources. If I wanted to nest  
permission specifically for say my customer resource then that would  
simply be:

map.resources :customers do |customer|  
customer.resources :permissions  
end

and this will give me url methods such as permissions\_url(@customer),  
permission\_url(@customer, :permission\_id) etc.

However what I want to achieve is a generic route definition that will  
give me this functionality across all my resources. Something possibly  
looking like:

map.resources :any do |any|  
any.resources :permissions  
end

where any can be any resource and have url methods like  
permissions\_url(@books),  
permission\_url(@itineraries, :permission\_id).

Any ideas will be appreaciated. Thanks.
