# Routing issue

**URL:** <https://www.ruby-forum.com/t/routing-issue/196974>\
**Category:** Rails\
**Created:** [June 21, 2009, 2:41pm UTC](https://www.ruby-forum.com/t/routing-issue/196974 "2009-06-21T14:41:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [June 21, 2009, 2:41pm UTC](https://www.ruby-forum.com/t/routing-issue/196974/1 "2009-06-21T14:41:08Z")

</div>

I have presently this in my routes.rb

map.resources :media\_containers , :has\_many=\> [:media\_items]

as the media\_items can have ‘libraries’ and ‘medias’ inheritances  
(STI)

rather than writing a route for a new media\_item, with a parameter to  
specify the type (elibrary or not) , like :

new\_media\_container\_media\_item\_path(@media\_container, :lib =\>  
“1”) … or :lib=\> “0”  
/media\_container/media\_container\_id/media\_items/new  
:action =\> new, :controller =\> media\_items

I would like to have an URL like this (hidding the /media\_items)

new\_media\_container\_elibrary\_path(@media\_container)  
/media\_container/media\_container\_id/new\_library  
:action =\> new\_library, :controller =\> media\_items (!!)  
and  
new\_media\_container\_emedia\_path(@media\_container)  
/media\_container/media\_container\_id/new\_media  
:action =\> new\_media :controller =\> media\_items (!!)

is this possible ? how should I define it in my routes.rb ?

thanks fyh

erwin
