Satchel
Satchel

Reputation: 16724

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 username/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?

Upvotes: 0

Views: 456

Answers (2)

Jan Minárik
Jan Minárik

Reputation: 3267

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.

Upvotes: 0

Chuck Callebs
Chuck Callebs

Reputation: 16441

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.

Upvotes: 1

Related Questions