开发者

How can I create human-readable usernames in Rails3 from unique ID or string?

My users submit an email and our Oauth provider generates a unique ID. I want to generate a human-friendly use开发者_开发知识库rname/slug for the users so they don't have to write one.

It's so that they can provide the URL as a linkage to other people. It may also be because we may introduce a "confidential" feature that hides identity but exposes this unique, human-friendly username that is generated for them.

How do I do that?


Just take the portion of their e-mail before the @ and append a number onto the end of it's already been taken. Given them an option to change it.


I'd recommend to make a list of pronounceable syllables and pick 2-4 of them randomly.

The syllables might be:

  1. Make a list of phonetic consonants (b,c,ch,d,t,th,...) and all phonetic vowels (a,o,oo,ou,ea,y,...) and generate all combinations consonant-vowel.
  2. Add combinations of two and more consonants, such as "pro", "bla", ...

I'm not so sure about English but this works very well in my language.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜