Does anyone know of a "suggested username" plugin for Ra开发者_运维技巧ils? I want something that will check if a username is available as a user types and display suggested usernames if unavailable. I know this would be easy to implement, just wondering if anyone has seen something out of the box.
Thanks!
I'm sorry to say that, after much research, I haven't found anything. No snippets. No gems. Nothing.
Looks like you'll have to roll your own. Be a pioneer and post your snippet somewhere. I doubt something like user name suggestions would warrant being packaged as a plugin, so post a snippet if you feel like contributing and rolling your own solution.
Jerry Luk has written a ruby gem called username_suggester that will plug into ActiveRecord to create userid suggestions. It currently depends on a database that supports the RLIKE operator in queries. I've used it in a Sinatra app, but it looks like it is designed for Rails. It is MIT Licensed. It uses a firstname and lastname attribute to generate suggestions, and it will also try appending numerals to the end of the userid. You can enforce userid length and you can also tell it userids you would like to exclude from suggestions.
For example, if you want a userid of tamoyal
but that userid is taken, and userids have to be at least 6 characters, here is a list of 5 userid suggestions it will generate (if they are unique):
amoyal
tamoyal
tonyamoyal
amoyalt
amoyaltony
精彩评论