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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On 25 фев, 15:16, "tm+" <mestdagh....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the answer. On 25 feb, 15:37, lq <liquidaut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> if you really up to rest, you should be ok with urls like this > /platforms/xbox360/games/halo-3But 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.> 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 > > On 25 фев, 15:16, "tm+" <mestdagh....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On 26 фев, 14:33, "tm+" <mestdagh....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the answer. > > On 25 feb, 15:37, lq <liquidaut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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. > > > 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 > > > On 25 фев, 15:16, "tm+" <mestdagh....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---