{"id":13558127,"url":"https://github.com/moners/uuid_parameter","last_synced_at":"2025-04-03T12:31:53.275Z","repository":{"id":220257425,"uuid":"149365147","full_name":"moners/uuid_parameter","owner":"moners","description":"  UUIDParameter handles a :uuid column and validation for any model.","archived":false,"fork":false,"pushed_at":"2018-10-13T22:56:18.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-04T08:37:28.820Z","etag":null,"topics":["rails5","ruby","uuid"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":false,"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/moners.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-09-18T23:42:40.000Z","updated_at":"2020-02-10T18:51:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"6bbc43d6-4c70-42ad-b058-517654c0071f","html_url":"https://github.com/moners/uuid_parameter","commit_stats":null,"previous_names":["moners/uuid_parameter"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moners%2Fuuid_parameter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moners%2Fuuid_parameter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moners%2Fuuid_parameter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moners%2Fuuid_parameter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moners","download_url":"https://codeload.github.com/moners/uuid_parameter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247002522,"owners_count":20867470,"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","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":["rails5","ruby","uuid"],"created_at":"2024-08-01T12:04:45.747Z","updated_at":"2025-04-03T12:31:53.261Z","avatar_url":"https://github.com/moners.png","language":"Ruby","funding_links":[],"categories":["Ruby","ruby"],"sub_categories":[],"readme":"# UUIDParameter\n\nThe `UUIDParameter` module provides support for UUIDs in `ActiveRecord` models.\n\nIt takes care of generating (if one was not provided), validating, and keeping\nthis UUID intact, protecting the `:uuid` field from being changed once set.\n\nModels including the `UUIDParameter` module will:\n- use their `:uuid` rather than their `:id` (primary key) for URLs.\n- accept an given UUID on creation to allow offline resource generation.\n\n### Features\n\n- Can be used with existing models (simply add a `uuid` column): saving the\n  model with `nil` values will provide a new UUID.\n- Does not affect existing primary key.\n- Can accept any valid random UUID (version 4) provided externally.\n- Automatically generates a UUID on `:create` if one is not set.\n- Only works with UUID version 4 (random).\n- Prevents changing the UUID once set.\n- Silently ignores any attempt at changing a set UUID.\n- Overrides `:to_param` to provide the UUID instead of the primary key.\n\n### Anti-Features\n\n- If the database already contains invalid UUIDv4 data, the affected records\n  will become **impossible to save**: this is to ensure that you can check your\n  referential integrity. You can still force `#reset_uuid!` to bypass this, or\n  use SQL directly in the database. (See #1)\n\n### I18n\n\nTranslations are in progress (See #2): specs are now passing thanks to a hack.\nTo add a new translation, please edit or create the corresponding file in\n[`config/locale`](https://gitlab.com/incommon.cc/uuid_parameter/tree/master/config/locale).\n\n## Usage\n\nAdd a `uuid` column to your model if it does not have one already:\n``` bash\n$ rails g migration AddUuidColumnToUser uuid:string{36}\n$ rails db:migrate\n```\n\nIf you're using Postgres, you should use the native `uuid` type instead:\n``` bash\n$ rails g migration AddUuidColumnToUser uuid:uuid\n$ rails db:migrate\n```\n\nThen, simply include the module in your model:\n``` ruby\nclass User \u003c ApplicationRecord\n  include UUIDParameter\nend\n\n# u = User.create  # Generates a new UUID\n# u.id             # =\u003e 123 (does not change primary key)\n# u.uuid           # =\u003e '8bb27724-7439-4965-9598-883419179b21'\n# u.to_param       # =\u003e '8bb27724-7439-4965-9598-883419179b21'\n# u.uuid = SecureRandom.uuid\n# u.save           # Silently ignores changes to :uuid\n# u.reload         # Instead, it restores the original:\n# u.uuid           # =\u003e '8bb27724-7439-4965-9598-883419179b21'\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n```ruby\ngem 'uuid_parameter'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n```bash\n$ gem install uuid_parameter\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on Gitlab at\nhttps://gitlab.com/incommon.cc/uuid_parameter.\n\nSee [ChangeLog] and commit messages.\n\nThe [Github repository] is a mirror to facilitate integration with other Rails\ndevelopment, but I don't like Microsoft, and never will. They may show the face\nthey like, they come from enemity and, as far as I'm concerned, will remain\nthere.\n\n[ChangeLog]: https://gitlab.com/incommon.cc/uuid_parameter/blob/master/CHANGELOG.md\n[Github repository]: https://github.com/moners/uuid_parameter\n\n# Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\nRun specifications with `bundle exec rake`.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\nSee `bundle exec rake -T` for more options.\n\nYou can now use `bin/console` to get a nice `Pry` console for development.\n\n## License\n\nThis gem is free software under the same [license] terms as Rails.\n\n[license]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoners%2Fuuid_parameter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoners%2Fuuid_parameter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoners%2Fuuid_parameter/lists"}