Skip to content
Use Hashids ( in your Rails app models.
Branch: master
Clone or download
Pull request Compare This branch is even with ruffnote:master.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin initial commit Apr 12, 2015
lib/hashid Add method for finding exclusively by hashid Mar 30, 2016
.gitignore initial commit Apr 12, 2015
.rspec initial commit Apr 12, 2015
.travis.yml Test on Ruby 2.0 series Mar 11, 2016 Update README and version number for decoding multiple ids Mar 30, 2016
Gemfile Configure for Travis CI Jan 2, 2016
LICENSE.txt initial commit Apr 12, 2015 Add travis status to readme Mar 11, 2016
Rakefile Set running tests as default rake task Apr 12, 2015
hashid-rails.gemspec Remove rake and bundler specific development versions Mar 11, 2016

Hashid Rails

Build Status Code Climate Test Coverage

This gem allows you to easily use Hashids in your Rails app. Instead of your models using sequential numbers like 1, 2, 3, they will instead have unique short hashes like "yLA6m0oM", "5bAyD0LO", and "wz3MZ49l". The database will still use integers under the hood, so this gem can be added or removed at any time.


Add this line to your application's Gemfile:

gem 'hashid-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hashid-rails


Just use Model#find passing in the hashid instead of the model id:

@person = Person.find(params[:hashid])


To customize the Hashids seed and ensure that another user of the gem cannot easily reverse engineer your ids, create an initializer and:

Hashid::Rails.configure do |config|
  config.secret = 'my secret'
  config.length = 6
  # config.alphabet is optional, hashids provides a default
  # alphabet that consists of all characters [a-zA-Z0-9]


After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to


  1. Fork it ([my-github-username]/hashid-rails/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
You can’t perform that action at this time.