# RESTful routes and resulting urls

**URL:** <https://www.ruby-forum.com/t/restful-routes-and-resulting-urls/76307>\
**Category:** Rails\
**Created:** [November 17, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/restful-routes-and-resulting-urls/76307 "2006-11-17T14:38:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![felix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/aeb1de/32.png) [@felix](https://www.ruby-forum.com/u/felix)\
**Post date:** [November 17, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/restful-routes-and-resulting-urls/76307/1 "2006-11-17T14:38:06Z")

</div>

with the old routing you used to be able to specify an abitrary route  
for any controller like so:

map.connect “blah/:action/:id”, :controller =\> ‘foo’

how can i do this with the new RESTful resources??

-felix

---

<div class="post-metadata">

**Author:** ![felix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/aeb1de/32.png) [@felix](https://www.ruby-forum.com/u/felix)\
**Post date:** [November 17, 2006, 2:54pm UTC](https://www.ruby-forum.com/t/restful-routes-and-resulting-urls/76307/2 "2006-11-17T14:54:08Z")

</div>

On 11/17/06, felix [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> with the old routing you used to be able to specify an abitrary route  
> for any controller like so:
> 
> map.connect “blah/:action/:id”, :controller =\> ‘foo’
> 
> how can i do this with the new RESTful resources??
> 
> -felix

You can mix old and new routes together.

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![felix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/aeb1de/32.png) [@felix](https://www.ruby-forum.com/u/felix)\
**Post date:** [November 17, 2006, 3:02pm UTC](https://www.ruby-forum.com/t/restful-routes-and-resulting-urls/76307/3 "2006-11-17T15:02:10Z")

</div>

I know I can have them both but I have some nested routes and the url  
is becoming a little long. what i wanted to do is ‘alias’ some of the  
sections on the url so that the result is much shorter.

an example:

/product\_categories/3/products

becomes

/cat/3/products

these are short examples but there are longer urls because of my model  
naming.

thanks for you suggestions.

-felix

---

<div class="post-metadata">

**Author:** ![felix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/aeb1de/32.png) [@felix](https://www.ruby-forum.com/u/felix)\
**Post date:** [November 17, 2006, 5:26pm UTC](https://www.ruby-forum.com/t/restful-routes-and-resulting-urls/76307/4 "2006-11-17T17:26:40Z")

</div>

On 11/17/06, felix [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /cat/3/products
> 
> these are short examples but there are longer urls because of my model  
> naming.
> 
> thanks for you suggestions.

Try this?  
map.resources :cats, :controller\_name =\> 'product\_categories do |cats|  
map.resources :products  
end

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)
