This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
README | Sun May 28 20:13:29 -0700 2006 | [dhh] |
| |
lib/ | Thu Oct 18 12:23:43 -0700 2007 | [jeremy] |
README
TokenGenerator
==============
Mix-in for classes that needs to have a token generated using MD5. You can set the length of the token
and provide it with an optional block that'll check the validity of the generated token (usually whether it's
already taken or not).
The two methods are generate_token, which will just return a new token, and set_token, which will assume
that there's a writer for the instance variable "token" and that the class has a "find_by_token" method to check
validity (if a duplicate exists, generate another token).
Examples:
class Invitation < ActiveRecord::Base
include TokenGenerator
before_create :set_token
end
class ImperialInvitation < ActiveRecord::Base
include TokenGenerator
before_create :set_token
private
def set_token
self.token = generate_token { |token| complies_to_imperial_standards?(token) }
end
end
Copyright (c) 2005 David Heinemeier Hansson, Marcel Molina Jr. released under the MIT license




