# Customize resource routes

**URL:** <https://www.ruby-forum.com/t/customize-resource-routes/130109>\
**Category:** Rails\
**Created:** [February 25, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/customize-resource-routes/130109 "2008-02-25T14:17:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmtmtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tmtmtm](https://www.ruby-forum.com/u/tmtmtm)\
**Post date:** [February 25, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/customize-resource-routes/130109/1 "2008-02-25T14:17:11Z")

</div>

Hi all,

I have this application that lists videogames, which i am rewriting to  
follow REST.

I need to have this url :  
/games/xbox360/halo-3 ( map.connect “/  
games/:platform\_id/:permalink”,:controller =\> “games”,:action =\>  
“show” )

This is no problem with map.connect, but with map.resources i can not  
make this.

map.resources :games do |game|  
game.resources :supply\_used  
end

The command makes the following url :  
/games/halo-3  
/games/halo-3/supply\_used/…

How can i still use map.resources and have :platform\_id in my url? Or  
do i need to make custom map.connects for each url?

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![tmtmtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tmtmtm](https://www.ruby-forum.com/u/tmtmtm)\
**Post date:** [February 25, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/customize-resource-routes/130109/2 "2008-02-25T15:37:43Z")

</div>

if you really up to rest, you should be ok with urls like this  
/platforms/xbox360/games/halo-3  
or, more practical  
/platforms/10-xbox360/games/2-halo-3  
where 10, 2 - record id’s

you’ll need to have  
map.resources :platforms { |platform| platform.resources :games }  
among your routes and tweak your Platform and Game to\_param method to  
return platform and game title instead of id (you will have to keep  
titles unique, tho) or id, followed by title, which is preferred

---

<div class="post-metadata">

**Author:** ![tmtmtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tmtmtm](https://www.ruby-forum.com/u/tmtmtm)\
**Post date:** [February 26, 2008, 1:34pm UTC](https://www.ruby-forum.com/t/customize-resource-routes/130109/3 "2008-02-26T13:34:04Z")

</div>

Thanks for the answer.

On 25 feb, 15:37, lq [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if you really up to rest, you should be ok with urls like this  
> /platforms/xbox360/games/halo-3

But admit it : /games/xbox360/halo-3 looks better than /platforms/  
xbox360/games/halo-3 🙂

Also, I would like to keep this url because it existed in the old  
website like that.

---

<div class="post-metadata">

**Author:** ![tmtmtm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tmtmtm](https://www.ruby-forum.com/u/tmtmtm)\
**Post date:** [February 27, 2008, 3:59am UTC](https://www.ruby-forum.com/t/customize-resource-routes/130109/4 "2008-02-27T03:59:03Z")

</div>

Legacy, I understand 🙂  
In my opinion, it looks shorter, but not more readable.  
However, it’s only up to how to lay out your uris, rest is not panacea  
and all map.resources is in fact doing is creating a set of named  
routes automatically for you.
