Skip to content
acts_as_hashed makes it easier to create unique non-discoverable URIs and all other sorts of uuid you may need in your app.
Ruby
Find file
Latest commit a1ddd1d Apr 4, 2014 @tomasmuller tomasmuller Merge pull request #5 from Helabs/add-maintainers-section-on-readme
Add maintainers section on readme.
Failed to load latest commit information.
lib
rails
spec
.gitignore
.rspec
.ruby-gemset
.ruby-version
CHANGELOG.md
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
acts_as_hashed.gemspec

README.md

ActsAsHashed

ActsAsHashed is helpful to set a hash_code column based on SecureRandom.hex(16).

Installation

Add this line to your application's Gemfile:

gem 'acts_as_hashed'

And then execute:

$ bundle

Or install it yourself as:

$ gem install acts_as_hashed

Usage

In your model:

class Order < ActiveRecord::Base
  acts_as_hashed

  ...
end

If you want to use the hashed_code instead of id on URLs:

class Order < ActiveRecord::Base
  acts_as_hashed

  def to_param
    hashed_code
  end

  ...
end

You can overwrite the method that generates the hash.

class Order < ActiveRecord::Base
  acts_as_hashed

  class << self
    def friendly_token
      SecureRandom.hex(5)
    end
  end
end

Create your migrations for the desired models

$ rails g migration AddHashedCodeToOrders hashed_code:string

Update your migration to add Model.update_missing_hashed_code

class AddHashedCodeToOrders < ActiveRecord::Migration
  def change
    add_column :orders, :hashed_code, :string
    Order.reset_column_information
    Order.update_missing_hashed_code
  end
end

Versioning

acts_as_hashed follow the Semantic Versioning

Issues

If you have problems, please create a Github Issue.

Contributing

Please see CONTRIBUTING.md for details.

Release

Follow this steps to release a new version of the gem.

  1. Test if everything is running ok;
  2. Change version of the gem on VERSION constant;
  3. Add the release date on the CHANGELOG;
  4. Do a commit "Bump version x.x.x", follow the semantic version;
  5. Run $ rake release, this will send the gem to the rubygems;
  6. Check if the gem is on the rubygems and the tags are correct on Github;

Maintainers

Credits

ActsAsHashed is maintained and funded by HE:labs. Thank you to all the contributors.

License

ActsAsHashed is Copyright © 2012-2014 HE:labs. It is free software, and may be redistributed under the terms specified in the LICENSE file.

Something went wrong with that request. Please try again.