No commit activity in last 3 years
No release in over 3 years
Generate tokens for ActiveRecord models in Ruby On Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

JTRailsTokenizable

Gem Version

JTRailsTokenizable generates tokens for ActiveRecord models in Ruby On Rails.

Installation

JTRailsTokenizable is distributed as a gem, which is how it should be used in your app.

Include the gem in your Gemfile:

gem 'jt-rails-tokenizable', '~> 1.0'

Usage

Basic usage

class User < ActiveRecord::Base
	tokenize :my_token_field
	tokenize :another_token_field, size: 20, validations: false
	tokenize :another_token_field, size: 20, only_digits: true
	...
end

You can change the size of the token (32 by default, which means 64 caracters) and disable the presence and uniqueness validations. The generation of token is using SecureRandom.hex or SecureRandom.random_number methods.

A new unique token is generated at the creation of the model. You can generate a new token with:

my_instance.generate_new_token(:my_token_field)
my_instance.save

# or directly

my_instance.generate_new_token!(:my_token_field)

Author

License

JTRailsTokenizable is released under the MIT license. See the LICENSE file for more info.