开发者

Suggested username plugin for Ruby on Rails?

开发者 https://www.devze.com 2022-12-15 01:03 出处:网络
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.

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
0

精彩评论

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

关注公众号