customize resource routes

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

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

Thanks for the answer.

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 :slight_smile:

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

Legacy, I understand :slight_smile: 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.