I converted one of my projects over to Edge Rails so I could start playing with REST. It was a piece of cake and everything seems to work great, except.... A couple of my controllers (providing wikki like functionality) expect text strings rather than ID Integers in the URL. Pre-REST, my routes.rd contained... map.connect ''wikki/:action/:title'', :controller => ''wikki'' And the controllers checked params[:title] to know which page to work with. The URL''s look like mysite.org/wikki/show/MainPage The table still has an ''id'' column, since Rails likes that, but I''ve added an additional index on the title column, since that''s what I''ll usually be using to look up pages. This is probably because I''ve only just started working with REST, but I haven''t found a RESTful way to map certain parts of the URL to alternate param keys. REST seems to expect that last field to always, always, always be :id... which I''m sure I can work with if necessary, but... :title is so much more descriptive and accurate. I''d really prefer to have my controllers do `WikkiPage.find_by_title(params[:title])`, and keep the beautiful RESTFUL URL''s like ''mysite.org/wikki/MainPage''. Maybe what I''m trying to do just isn''t appropriate with REST, or I''m overlooking something obvious. Any suggestions or enlightening would be greatly appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello Jon,> This is probably because I've only just started working > with REST, but I haven't found a RESTful way to map > certain parts of the URL to alternate param keys. REST > seems to expect that last field to always, always, always > be :id... which I'm sure I can work with if necessary, but... > :title is so much more descriptive and accurate. I'd really > prefer to have my controllers do `WikkiPage.find_by_title( > params[:title])`, and keep the beautiful RESTFUL URL's like > 'mysite.org/wikki/MainPage'. Maybe what I'm trying to do > just isn't appropriate with REST, or I'm overlooking something > obvious. Any suggestions or enlightening would be > greatly appreciated.Have a look at resource_hacks plugin : http://www.jvoorhis.com/articles/2006/08/01/announcing-resource_hacks code here : http://svn.planetargon.org/rails/plugins/resource_hacks HTH, -- Jean-François. -- À la renverse. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---
AhHA! Thanks. Jean-François wrote:> Have a look at resource_hacks plugin : > > http://www.jvoorhis.com/articles/2006/08/01/announcing-resource_hacks > > code here : > http://svn.planetargon.org/rails/plugins/resource_hacks > > HTH, > > -- Jean-François. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---