Okay, so I''m trying to have a URL like the following (which uses a key generated at random): societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff/edit Where do I change the default behavior from using the ID, to another value of that object?
Ben Wilson wrote:> Okay, so I''m trying to have a URL like the following (which uses a key > generated at random): > > societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff > societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff/edit > > Where do I change the default behavior from using the ID, to another > value of that object?Did you try this in routes - map.connect ''societies/:something/edit'', :action=>''aaa'', :controller=>''ccc'' - example. societies/:rkey/edit -- Posted via http://www.ruby-forum.com/.
2009/7/7, Rails List <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Ben Wilson wrote: >> Okay, so I''m trying to have a URL like the following (which uses a key >> generated at random): >> >> societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff >> societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff/edit >> >> Where do I change the default behavior from using the ID, to another >> value of that object? > > Did you try this in routes - > > map.connect ''societies/:something/edit'', :action=>''aaa'', > :controller=>''ccc'' > > - example. societies/:rkey/edit > -- > Posted via http://www.ruby-forum.com/. > > > >-- Von meinen Mobilgerät aus gesendet
You can overwrite to_param to return the random thing and use find_by_random_thing params[:id] in your controller actions 2009/7/8, mike <mikezter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> 2009/7/7, Rails List <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> Ben Wilson wrote: >>> Okay, so I''m trying to have a URL like the following (which uses a key >>> generated at random): >>> >>> societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff >>> societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff/edit >>> >>> Where do I change the default behavior from using the ID, to another >>> value of that object? >> >> Did you try this in routes - >> >> map.connect ''societies/:something/edit'', :action=>''aaa'', >> :controller=>''ccc'' >> >> - example. societies/:rkey/edit >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> >> > > -- > Von meinen Mobilgerät aus gesendet >-- Von meinen Mobilgerät aus gesendet
On Jul 7, 1:32 am, Rails List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> BenWilsonwrote: > > Okay, so I''m trying to have a URL like the following (which uses a key > > generated at random): > > > societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff > > societies/6b241c631c6beaa89c889b9fb388caef9f617900ca1eff/edit > > > Where do I change the default behavior from using the ID, to another > > value of that object? > > Did you try this in routes - > > map.connect ''societies/:something/edit'', :action=>''aaa'', > :controller=>''ccc'' > > - example. societies/:rkey/editI''d like to avoid rewriting routes (I mean, I can do map.resources :societies) I''ll try the to_params, that one slipped my mind.