Remove controller name from URL > nested routes

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

I want

http://example/continent/azie/japan/aomori

How can i realize this…?

Grtz…remco

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

I want

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.