Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.
/ hashable Public archive

Hashable allows you to generate and save hash id for ActiveRecord models.

License

Notifications You must be signed in to change notification settings

rdelandesen/hashable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hashable

Hashable allows you to generate and save hash id for ActiveRecord models.

Build Status

For example :

ID Hash ID
1 ejRe
2 bk5e
3 el5a

Hashable uses HashIds.rb encoding.

N.B. If you don't need to save hash id in database, you can use HashId Rails.

Installation

Add this line to your application's Gemfile:

gem 'hashable', github: 'rdelandesen/hashable'

And then execute:

$ bundle

Usage

Model setup

class User < ActiveRecord::Base
  hashable.config do |c|
    c.attr = :hash_id
    
    # Optional
    c.source     = :id
    c.salt       = 'replaceit' # by default => ''
    c.alphabet   = 'abcdefxyz' # by default => all letters + 0..9
    c.min_length = 4 # by default
  end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rdelandesen/hashable.

License

The gem is available as open source under the terms of the MIT License.

About

Hashable allows you to generate and save hash id for ActiveRecord models.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published