Generates username suggestions
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec tests are green and roses are blue :) this stuff is working for rails… Oct 3, 2012
.gitignore
Gemfile
MIT-LICENSE UsernameSuggester is now up Jul 1, 2010
README.rdoc
Rakefile
init.rb
username_suggester.gemspec

README.rdoc

TODO: Rewrite the readme at it's soooo old :(

UsernameSuggester

It generates username suggestions for users. It works with MySQL and any DB that supports “RLIKE”. If enough people request, I will add the support for not using RLIKE for those DB does not support it. (although it will be slower)

Usage

In your environment.rb, add:

config.gem 'username_suggester'

Assume you have an User model with attributes :username, :firstname, :lastname

class User < ActiveRecord::Base
  suggestions_for :username, :num_suggestions => 5,
    :first_name_attribute => :firstname, :last_name_attribute => lastname

  ...

end

And now you can call the suggestion function like the following:

user = User.new(:firstname => "Jerry", :lastname => "Luk")
user.username_suggestions

You can also filter the suggestions, let's say you want the username to contain at least 4 characters:

suggestions_for :username, :num_suggestions => 10,
  :validate => Proc.new { |username| username.length >= 4 }

Copyright © 2010 Presdo, released under the MIT license