Project

ar-tokens

0.0
No commit activity in last 3 years
No release in over 3 years
This gem lets you easily generate tokens on ruby objects and provides additional methods on ActiveRecord::Base to generate tokens on records
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Gem Version Build Status Code Climate Coverage Status

For generating a token on an active record column you can use tokenize

Parameters

  • column: the column of the active record
  • options: some options for generating the token
    • :length: the token length (default: 8)
    • :uniq: whether the token must be uniq or not (default: true)
    • :scope: the column for the scope to check the uniqueness (default: nil)
    • :characters: an array of characters the tokens should be build from (default: a-zA-Z0-9)

Example

  class User < ActiveRecord::Base
    tokenize :email_confirmation_token, length: 16
  end

this is equal to

  class User < ActiveRecord::Base
    before_validation on: :create do |obj|
      obj.generate_token :email_confirmation_token, length: 16
    end
  end

Installation

Currently the gem is not available on rubyforge, so you have to install it with git:

  gem 'ar-tokens'

License

This project rocks and uses MIT-LICENSE.