{"id":15405162,"url":"https://github.com/fnando/permalink","last_synced_at":"2025-09-11T13:32:26.614Z","repository":{"id":415890,"uuid":"35454","full_name":"fnando/permalink","owner":"fnando","description":"Add permalink support to Rails apps with this plugin","archived":false,"fork":false,"pushed_at":"2024-04-23T01:10:02.000Z","size":74,"stargazers_count":40,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-02T13:31:57.676Z","etag":null,"topics":[],"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/fnando.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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},"funding":{"github":["fnando"],"custom":["https://www.paypal.me/nandovieira/🍕"]}},"created_at":"2008-07-19T15:05:10.000Z","updated_at":"2024-04-23T01:10:04.000Z","dependencies_parsed_at":"2024-10-20T12:39:58.433Z","dependency_job_id":null,"html_url":"https://github.com/fnando/permalink","commit_stats":{"total_commits":58,"total_committers":4,"mean_commits":14.5,"dds":"0.15517241379310343","last_synced_commit":"caef96d8a953d1bf27a9b36caa6cdc7ef87f2ab4"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fpermalink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fpermalink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fpermalink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fpermalink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/permalink/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232651274,"owners_count":18555965,"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":[],"created_at":"2024-10-01T16:15:17.089Z","updated_at":"2025-01-05T23:18:41.746Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":["https://github.com/sponsors/fnando","https://www.paypal.me/nandovieira/🍕"],"categories":[],"sub_categories":[],"readme":"# Permalink\n\n[![test](https://github.com/fnando/permalink/actions/workflows/test.yml/badge.svg)](https://github.com/fnando/permalink/actions/workflows/test.yml)\n[![Gem](https://img.shields.io/gem/v/permalink.svg)](https://rubygems.org/gems/permalink)\n[![Gem](https://img.shields.io/gem/dt/permalink.svg)](https://rubygems.org/gems/permalink)\n\n## Installation\n\n    gem install permalink\n\n## Usage\n\n\u003e [!NOTE]\n\u003e\n\u003e To have the method `permalink` available, you need to inject\n\u003e `Permalink.active_record` on each model, or use something like your\n\u003e `ApplicationModel`.\n\n```ruby\nclass ApplicationRecord \u003c ActiveRecord::Base\n  primary_abstract_class\n  include Permalink.active_record\nend\n```\n\nAdd the method call `permalink` to your model. Your model should have a\n`permalink` attribute.\n\n```ruby\nclass Page \u003c ApplicationRecord\n  permalink :title\nend\n```\n\nYou can specify the permalink field:\n\n```ruby\nclass Page \u003c ApplicationRecord\n  permalink :title, to: \"title_permalink\"\nend\n```\n\nIf you don't want to use `permalink`, you can call `Permalink.call(\"some text\")`\nstring method and manage the permalink process by yourself.\n\nPermalinks are not unique by default. `permalink` overrides `to_param` as\nfollowing:\n\n```ruby\ndef to_param\n  \"#{id}-#{permalink}\"\nend\n```\n\nYou can define the `to_param` format:\n\n```ruby\nclass Page \u003c ApplicationRecord\n  permalink :title, to_param: %w(id permalink page)\nend\n```\n\nThe above settings will generate something link `100-some-title-page`. By\noverriding `to_param` method you don't have to change a thing on your app\nroutes.\n\nIf you want to generate unique permalink, use the `:unique` option:\n\n```ruby\nclass Page \u003c ApplicationRecord\n  permalink :title, unique: true, to_param: \"permalink\"\nend\n```\n\nThe permalink can be tied to a given scope. Let's say you want to have unique\npermalinks by user. Just set the `:scope` option.\n\n```ruby\nclass Page \u003c ApplicationRecord\n  belongs_to :user\n  permalink :title, unique: true, scope: \"user_id\"\nend\n\nuser = User.first\nanother_user = User.last\n\npage = user.pages.create(title: 'Hello')\npage.permalink #=\u003e hello\n\nanother_page = another_user.pages.create(title: 'Hello')\nanother_page.permalink #=\u003e hello\n```\n\nThe permalink is generated using `ActiveSupport::Multibyte::Chars` class; this\nmeans that characters will properly replaced from `áéíó` to `aeio`, for\ninstance.\n\nThe permalink is created when `before_validation` callback is evaluated. This\nplugin also tries to generate a permalink when `before_save` callback is\nevaluated and the instance has no permalink set.\n\nYou can force the permalink generation by setting the `:force` option.\n\n```ruby\nclass Page \u003c ApplicationRecord\n  permalink :title, force: true\nend\n```\n\n## License\n\nCopyright (c) 2011-2024 Nando Vieira, released under the MIT license\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fpermalink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Fpermalink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fpermalink/lists"}