I have a project in which the client is insistent on all content URLs being top level. This includes URLs across very different resource types, for example:
/products #=> The Category "products"
/privacy #=> A content-managed SystemPage "privacy"
/foo-bar-baz #=> An Article "foo bar baz" (user generated, no less)
Obiviously, this is problematic, raising at least two technical issues:
- Routing cannot be handled via a pattern-based approach
- The slugs for these different pieces of content need to be unique across tables.
This is not to mention that it feels antithetical to Rails itself, and is certainly not congruent with the framework's expected patterns.
That being said, I'm wondering if there's a reasonably sane way to achieve this.
My first instinct is to maintain a table of "slugs" which map slugs to resource type and perform a lookup by slug at site root, then, if somehow possible, forward the request to the appropriate controller. I'm about to research that possibility, but I thought I should see if anyone else has a solution to this problem (besides firing the client).