Sha256: 41db27851a5295c1c75eea1aea298f9df08ca480feb47153f9eee22aa2745b6b
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
= 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 (c) 2010 Presdo, released under the MIT license
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
username_suggester-0.2.2 | README.rdoc |
username_suggester-0.2.1 | README.rdoc |
username_suggester-0.2.0 | README.rdoc |