RESTful Question

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.

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.

AhHA! Thanks.

Jean-François wrote: