{"id":19174930,"url":"https://github.com/dtaniwaki/acts_as_hashids","last_synced_at":"2025-11-11T19:36:56.207Z","repository":{"id":8392195,"uuid":"58236013","full_name":"dtaniwaki/acts_as_hashids","owner":"dtaniwaki","description":"Use Youtube-Like ID in ActiveRecord seamlessly.","archived":false,"fork":false,"pushed_at":"2024-08-16T14:05:17.000Z","size":72,"stargazers_count":89,"open_issues_count":6,"forks_count":27,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-16T21:49:58.393Z","etag":null,"topics":["actioncontroller","activerecord","hashids","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtaniwaki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-06T21:31:48.000Z","updated_at":"2025-03-31T19:48:48.000Z","dependencies_parsed_at":"2023-01-13T14:46:54.697Z","dependency_job_id":"1aab8c5e-4a3b-42c4-90cc-3b333de44d2c","html_url":"https://github.com/dtaniwaki/acts_as_hashids","commit_stats":{"total_commits":61,"total_committers":8,"mean_commits":7.625,"dds":0.1311475409836066,"last_synced_commit":"82380950a56617bc341ca5d698637c172b5ebd56"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/dtaniwaki/acts_as_hashids","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtaniwaki%2Facts_as_hashids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtaniwaki%2Facts_as_hashids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtaniwaki%2Facts_as_hashids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtaniwaki%2Facts_as_hashids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtaniwaki","download_url":"https://codeload.github.com/dtaniwaki/acts_as_hashids/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtaniwaki%2Facts_as_hashids/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283921118,"owners_count":26916743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actioncontroller","activerecord","hashids","rails","ruby"],"created_at":"2024-11-09T10:19:46.713Z","updated_at":"2025-11-11T19:36:56.177Z","avatar_url":"https://github.com/dtaniwaki.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# acts_as_hashids\n\n[![Gem Version][gem-image]][gem-link]\n[![Download][download-image]][download-link]\n[![Build Status][build-image]][build-link]\n[![Coverage Status][cov-image]][cov-link]\n[![Code Climate][gpa-image]][gpa-link]\n\nUse [Hashids](https://github.com/peterhellberg/hashids.rb) (a.k.a. Youtube-Like ID) in ActiveRecord seamlessly.\n\n## Installation\n\nAdd the acts_as_hashids gem to your Gemfile.\n\n```ruby\ngem \"acts_as_hashids\"\n```\n\nAnd run `bundle install`.\n\n## Usage\n\nActivate the function in any model of `ActiveRecord::Base`.\n\n```ruby\nclass Foo \u003c ActiveRecord::Base\n  acts_as_hashids\nend\n\nfoo = Foo.create\n# =\u003e #\u003cFoo:0x007feb5978a7c0 id: 3\u003e\n\nfoo.to_param\n# =\u003e \"ePQgabdg\"\n\nFoo.find(3)\n# =\u003e #\u003cFoo:0x007feb5978a7c0 id: 3\u003e\n\nFoo.find(\"ePQgabdg\")\n# =\u003e #\u003cFoo:0x007feb5978a7c0 id: 3\u003e\n\nFoo.with_hashids(\"ePQgabdg\").first\n# =\u003e #\u003cFoo:0x007feb5978a7c0 id: 3\u003e\n```\n\n### Use in Rails\n\nOnly one thing you need to hash ids is put `acts_as_hashids` in `ApplicationRecord`, then you will see hash ids in routes URL and they are handled correctly as long as you use `find` to find records.\n\n## Options\n\n### length\n\nYou can customize the length of hash ids per model. The default length is 8.\n\n```ruby\nclass Foo \u003c ActiveRecord::Base\n  acts_as_hashids length: 2\nend\n\nFoo.create.to_param\n# =\u003e \"Rx\"\n```\n\n### secret\n\nYou can customize the secret of hash ids per model. The default secret is the class name. The name of base class is used for STI.\n\n```ruby\nclass Foo1 \u003c ActiveRecord::Base\n  acts_as_hashids secret: 'my secret'\nend\n\nclass Foo2 \u003c ActiveRecord::Base\n  acts_as_hashids secret: 'my secret'\nend\n\nFoo1.create.to_param\n# =\u003e \"RxQce3a2\"\n\nFoo2.create.to_param\n# =\u003e \"RxQce3a2\"\n```\n\n### alphabet\n\nSpecify which characters you use to generate hashids.\n\n```rb\nclass Foo \u003c ActiveRecord::Base\n  acts_as_hashids alphabet: '0123456789uvwxyz'\nend\n\nFoo.create(id: 1).to_param\n# =\u003e \"4xw8zwyv\"\n```\n\n## Test\n\nExecute the command below to run rspec and rubocop.\n\n```\nbundle exec rake\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new [Pull Request](../../pull/new/master)\n\n## Copyright\n\nCopyright (c) 2014 Daisuke Taniwaki. See [LICENSE](LICENSE) for details.\n\n\n\n\n[gem-image]:   https://badge.fury.io/rb/acts_as_hashids.svg\n[gem-link]:    http://badge.fury.io/rb/acts_as_hashids\n[download-image]:https://img.shields.io/gem/dt/acts_as_hashids.svg\n[download-link]:https://rubygems.org/gems/acts_as_hashids\n[build-image]: https://github.com/dtaniwaki/acts_as_hashids/actions/workflows/test.yml/badge.svg\n[build-link]:  https://github.com/dtaniwaki/acts_as_hashids/actions/workflows/test.yml\n[cov-image]:   https://coveralls.io/repos/dtaniwaki/acts_as_hashids/badge.png\n[cov-link]:    https://coveralls.io/r/dtaniwaki/acts_as_hashids\n[gpa-image]:   https://codeclimate.com/github/dtaniwaki/acts_as_hashids.png\n[gpa-link]:    https://codeclimate.com/github/dtaniwaki/acts_as_hashids\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtaniwaki%2Facts_as_hashids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtaniwaki%2Facts_as_hashids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtaniwaki%2Facts_as_hashids/lists"}