For anyone else who wanted to use nested "to_param" with restful
routing, this was the snippet i had to resort to:
identify(Location => :location_to_param) do
identify(Shop => :shop_to_param) do
resources :locations do |location|
resources :shops
end
end
where i defined location_to_param in the location model.
On Nov 16, 5:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thanks very much for that insight, Yehuda.
>
> It "sort of" works. I define the following in my router.rb:
> resources :locations do |location|
> resources :shops
> end
> #I have to repeat this else or i get a bad request on the urls.
>
> identify(Location => :to_param, Shop => :to_param) do
> resources :locations do |location|
> resources :shops
> end
> end
>
> however, when i specify url(:location, location, shop), it generates
> "location/location_id-location_name/shops/location_id-location_name"
> rather than the "location/location_id-location_name/shops/shop_id-
> shop_name"
>
> Tommy
>
> On Nov 16, 2:32 pm, "Yehuda Katz" <[EMAIL PROTECTED]> wrote:
>
> > You can do:
> > identify(Superklass => :meth) do
> > # routes here
> > end
>
> > -- Yehuda
>
> > On Sun, Nov 16, 2008 at 8:55 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:
>
> > > > If you ask me, binding resource information to the model is idiotic,
> > > > as the model is NOT the resource, it's a sub-set of it.
> > > > But hey, we work with what we've got ;-)
>
> > > Yes, I would prefer a solution like this:
> > > in router.rb
> > > resources locations, :default_param => ":id-:name"
> > > so when the you call url(:location, location), it will fill it in with
> > > "/location/3-san_diego" rather than force everything to using the id "/
> > > location/3"
>
> > > This solves the issue of search/replacing all the url methods already
> > > used and the default resource routes are preserved.
>
> > > But Merb doesn't support this way?
>
> > --
> > Yehuda Katz
> > Developer | Engine Yard
> > (ph) 718.877.1325
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---