Routing: How do I use what is left from an URL

Sascha Ebach
Sat, 19 Feb 2005 13:47:40 -0000

Hi,

I have this scenario. I have the full path of a page stored in the
database (column ''path''). I want to be able to have very short
urls for
retrieving the pages, so i have this route in my map

map.connect ''-/:title'', :controller =>
''page'',
   :action => ''view_by_title'', :title => nil

so when I go to /-/PageTitle it gets me the page PageTitle. Pages can
have additional path prefixes, so I can have categories. For example
"/products" or "/articles/ruby/rails". Let''s say I
have lots of
categories and I have many articles in them. One is "Writing the
simplest CMS that could possibly be useful with Ruby on Rails" or short
"WTSCMSTCPBUWROR". It would have a path of
"/articles/ruby/rails" and
the title would be "WTSCMSTCPBUWROR". So the full url to retrieve this
article would be:

/-/articles/ruby/rails/WTSCMSTCPBUWROR

I don''t know how long the path is going to be. The page could lie in
root or have several directory levels.

As soon as I try to use the above route I get a routing error. So what
do I need to do to make this work? I would need something like this:


map.connect ''-/:title[/*]''

The [/*] would indicate additional optional url directories. The
"rest"
of the url.

Is this planned or is it already possible with routes? I know it is
possible with mod_rewrite, but I think this shouldn''t be needed, right?

Sascha