views:

142

answers:

1

I want to have username URLs and Base 58 short URLs to resources both off of the root url like this:

http://mydomain.com/username #=> goes to given user

http://mydomain.com/a3x9 #=> goes to given story

I am aware of the possibilities of a user names conflicting with short urls, and I have a workaround, but what I can't figure out is the best way to set this up in rails.

Can I do it in rails routes? Should I do something with a piece of Rack middleware? Should I set up a routing controller?

Please let me know the best way to do this. Thanks so much!

+1  A: 

Without knowing your workaround, it's hard to say for sure, but I would prefer the router if possible for simplicity's sake. I use Rack middleware only when I need to actually muck with the request itself. This may overcomplicate things for you. A controller to handle it should work fine as well if the router can't do it. Rails 3 has a powerful router, but 2's is not so much. You might also want to look at setting up a Rails Metal endpoint to handle this.

x1a4