Cms like routes

Hi! I need to be able to construct urls that looks something like
this: news/sport/1-article. The news/sport part is a section that an
article can be posted in. The idea is that sections can be nested and
that it should be reflected in the url. How’s that possible to do
without globbing the whole route to a custom controller and then break
it apart?

I tried something like this in the routes.rb without any luck:
map.connect ‘*section/:id’, :controller => ‘articles’, :action =>
‘show’. If I change it to map.connect ‘*section/articles/:id’ it
works but then i need that articles part in the routes all the time,
not a very good solution:)

Thanks in advance!

I think I solved it my self actually!

It turns out that if you name the id parameter something else (like
article_id) Rails actually divides the params correctly.

So this route:
map.article_by_id ‘*sections/:article_id’, :controller =>
“articles”, :action => “show”, :article_id => /\d|\d-(.+)/
would detect something like this:
news/sports/football/4
and Rails would route to the article controller and show action width
the following params: {“sections”=>[“news”, “sports”, “football”],
“article_id”=>“4”}

Pretty cool, and hopefully this helps someone else with the same
problem that I had.

I think I solved it my self actually!
It turns out that if you name the id parameter something else (like
article_id) Rails actually divides the params correctly.
So this route:
map.article_by_id ‘*sections/:article_id’, :controller =>
“articles”, :action => “show”, :article_id => /\d|\d-(.+)/
would detect something like this:
news/sports/football/4
and Rails would route to the article controller and show action with
the following params: {“sections”=>[“news”, “sports”, “football”],
“article_id”=>“4”}
Pretty cool, and hopefully this helps someone else with the same
problem that I had.