No commit activity in last 3 years
No release in over 3 years
Unique token strings for your activerecord models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
>= 0

Runtime

>= 6.0.3.1
 Project Readme

Installation

Add to your Gemfile:

gem 'activerecord-has_token'

Then you can add has_token to your model(s):

class Post < ActiveRecord::Base
  has_token # defaults to 'token' attribute
  has_token token_attribute: :slug, length: 20 # (optional) you can specify an attribute and/or length 
end

post = Post.new
post.save
post.token # => "pX27z5"
post.slug # => "qa4d9kfn5ytqzxc0lpok"

post.regenerate_token # => "jd73k0"
post.regenerate_slug # => "7dk893kjdbt6dmnolps4"

Tests

$ rake test