I’ve been digging pretty deeply into the new routing capabilities in
Rails 3 and have been very impressed by what I’ve seen so far.
However, in my exploration I haven’t been able to figure out one final
piece — it’s a bit complicated to summarize, so here’s a short example
of what I would like to do:
Let’s say I’ve got a simple set of forums software, with a controller
named Forum. In the data model that Forum uses, there are a bunch of
topics with subtopics:
Although that’s the way the structure looks today, there’s nothing
that would prevent an admin from adding topics under “Bar” at a
moment’s notice — so the main point is that the structure could
I’d like to be able to write a routing rule such that I could match
“http://example.com/Foo/Baz/Rick” to a specific action in the Forum
controller and know the order of the parameters that were passed in.
In a perfect world, I’d really only like to forward the request on to
the Forum controller if the path is sensible. I have some feeling
that I might be able to do something creative with :constraints, but
I’m not quite sure if I can pass in an appropriate method or proc that
would have access to the necessary data to do that check.
Can anyone out there with some better insight point me in the right