# Remove controller name from URL \> nested routes

**URL:** <https://www.ruby-forum.com/t/remove-controller-name-from-url-nested-routes/137679>\
**Category:** Rails\
**Created:** [May 15, 2008, 9:16am UTC](https://www.ruby-forum.com/t/remove-controller-name-from-url-nested-routes/137679 "2008-05-15T09:16:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![remco123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/779978/32.png) [@remco123](https://www.ruby-forum.com/u/remco123)\
**Post date:** [May 15, 2008, 9:16am UTC](https://www.ruby-forum.com/t/remove-controller-name-from-url-nested-routes/137679/1 "2008-05-15T09:16:03Z")

</div>

Hi…

There are my nested routes

map.resources :continent do |continent|  
continent.resources :land do |land|  
land.resources :destination  
end  
end

By example it generates this url

[http://example/continent/azie/land/japan/destination/aomori](http://example/continent/azie/land/japan/destination/aomori)

I want

[http://example/continent/azie/japan/aomori](http://example/continent/azie/japan/aomori)

How can i realize this…?

Grtz…remco

---

<div class="post-metadata">

**Author:** ![remco123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/779978/32.png) [@remco123](https://www.ruby-forum.com/u/remco123)\
**Post date:** [May 15, 2008, 9:43pm UTC](https://www.ruby-forum.com/t/remove-controller-name-from-url-nested-routes/137679/2 "2008-05-15T21:43:54Z")

</div>

Remco Z. wrote:

> Hi…
> 
> There are my nested routes
> 
> map.resources :continent do |continent|  
> continent.resources :land do |land|  
> land.resources :destination  
> end  
> end
> 
> By example it generates this url
> 
> [http://example/continent/azie/land/japan/destination/aomori](http://example/continent/azie/land/japan/destination/aomori)
> 
> I want
> 
> [http://example/continent/azie/japan/aomori](http://example/continent/azie/japan/aomori)
> 
> How can i realize this…?
> 
> Grtz…remco

Thats the way nested resources work.

/:controller\_one/:id\_one/:controller\_two/:id\_two/…etc…

This is because a resource may have more than 1 type of child resource  
and there needs to be a way to figure out which you are talking about.

You want a custom route, like:

map.destination "continent/:contintent\_id/:land\_id/:id

Now you can do:

destination\_path(:continent\_id =\> ‘azie’, :land\_id =\> ‘japan’, :id =\>  
‘aomori’)

to get:

/continent/azie/japan/aomori

RESTful routes don’t always give you everything you need.
