开发者

Best way to generate bit.ly or twitpic style ids?

For a personal project I'm working on, I'd like to generate ids for objects on my website in the same style as sit开发者_如何学JAVAes like bit.ly and twitpic. Sending users to example.com/4gwv9k would let me get the item with id 9gwv9k. Is this simply a question of auto-incrementing on a base-36 scheme or is there some underlying, non-incrementing magic going on?

This is all being done in Rails, so any gem support would be welcome as well.


You may use autoincrement integer translated to 62 based number (26 small letters + 26 cap letters + 10 digits)


Here's an example on I did it in Sinatra.

https://github.com/chrisledet/shorty_url

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜