{"id":18426147,"url":"https://github.com/wework/freeze-tag","last_synced_at":"2025-04-07T16:32:20.287Z","repository":{"id":56847715,"uuid":"128124628","full_name":"wework/freeze-tag","owner":"wework","description":"A rails gem for a more \"Stateless\" tagging experience","archived":false,"fork":false,"pushed_at":"2018-04-16T20:19:25.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-19T05:48:57.387Z","etag":null,"topics":["ruby-gem","ruby-on-rails","rubygems","tagger","tagging"],"latest_commit_sha":null,"homepage":null,"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/wework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-04T21:32:19.000Z","updated_at":"2020-09-20T16:04:26.000Z","dependencies_parsed_at":"2022-09-09T06:23:25.972Z","dependency_job_id":null,"html_url":"https://github.com/wework/freeze-tag","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Ffreeze-tag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Ffreeze-tag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Ffreeze-tag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Ffreeze-tag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wework","download_url":"https://codeload.github.com/wework/freeze-tag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247688103,"owners_count":20979606,"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":["ruby-gem","ruby-on-rails","rubygems","tagger","tagging"],"created_at":"2024-11-06T05:07:01.515Z","updated_at":"2025-04-07T16:32:19.933Z","avatar_url":"https://github.com/wework.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FreezeTag\n\nHowdy,\n\nThe de facto tagging library for almost every Ruby on Rails project has been [Acts As Taggable On Gem](https://github.com/mbleigh/acts-as-taggable-on) which provides a simple interface for polymorphic tagging of your models. \n\nAs excellent and useful as ActsAsTaggable is, this library is attempt to reconcile some shortcomings:\n\n1. Freeze tag allows for a more \"stateless\" approach to tagging. \n\nTags are never deleted, instead they have an \"expired_at\" column, which can be updated to make them inactive.\n\n2. The associations are more simple.\n\nTags are held in a single table which holds the content of the tag (its name) and the association back to the model instance its attached to.\nThis has some advantages including simpler querying, joining, etc., but obviously drawbacks as well.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'freeze_tag'\n```\n\nAnd then execute:\n\n    $ bundle\n\nCreate the tables:\n\n1. Run the installer:\n\n```\n$ rails g freeze_tag:install\n```\n\nThis adds a migration to create your \"freeze_tags\" table\n\n2. Confirm your implementation.\n\nSince Freeze tags creates a polymorphic association between tags and models, its necessary to confirm the type of primary keys the models in your application use. Open the migration and choose the correct option for you. \n\n3. Run the migration\n\n```\nrake db:migrate\n```\n\n4. Add:\n```ruby\ninclude FreezeTag::Taggable\n```\nto the top of any model you'd like to start tagging.\n\n5. Case sensitivity, add:\n```ruby\ndef self.freeze_tag_case_sensitive\n  true\nend\n```\nTo your model and all tags will be saved as lowercase\n\n#### Tagging a record:\n\nA single tag:\n\n```ruby\nmy_model_instance.freeze_tag(as: \"Fancy\")\n```\n\nOr apply multiple tags:\n\n```ruby\nmy_model_instance.freeze_tag(as: [\"Fancy\", \"Schmancy\"])\n```\n\nOr apply multiple tags and expire all other ones:\n\n```ruby\nmy_model_instance.freeze_tag(as: [\"Fancy\", \"Schmancy\"], expire_others: true)\n```\n\n##### Tagging a record, with list:\nThere may be times you want multiple lists of tags, i.e. users with skills, AND hobbies\n\nAll the same methods above work, simple pass a list as an argument.\n\n```ruby\nmy_model_instance.freeze_tag(as: \"Web Design\", list: \"Skills\")\n```\n\n##### Tagging while creating:\nYou can also use the same style/attributes to tag while creating instances\n\n```ruby\nmy_model_instance = MyModel.new(name: \"MyModelName\", freeze_tagged: [{\n  as: [\"Cool\", \"Beans\"],\n  list: \"Ideas\",\n  expire_others: true\n}])\n\nmy_model_instance.save\n```\n\n#### Accessing tags:\n\nAll the current \"active\" tags as a simple array of strings.\n\n```ruby\nmy_model_instance.freeze_tag_list\n[\"Happy\", \"Go\", \"Lucky\"]\n```\n\nAll the tags as a simple array of strings.\n\n```ruby\nmy_model_instance.freeze_tag_list(only_active: false)\n[\"Happy\", \"Go\", \"Lucky\", \"Sad\"]\n```\n\nAll the tags, in a list, as a simple array of strings.\n\n```ruby\nmy_model_instance.freeze_tag_list(list: \"Skills\")\n[\"Web Design\", \"Illustration\"]\n```\n\nActive Record association of all tags\n\n```ruby\nmy_model_instance.freeze_tags\n```\n\nActive Record association of all \"active\" tags\n```ruby\nmy_model_instance.active_freeze_tags\n```\n\nYou can change queries to the above to filter by anything.\n```ruby\nmy_model_instance.freeze_tags.where(list: \"Skills\")\nmy_model_instance.active_freeze_tags.where(list: \"Skills\")\n```\n\n#### Retrieving records that have been tagged:\n\nCurrently tagged with (only unexpired)\n```ruby\nMyModel.freeze_tagged(as: \"Fancy\")\n```\n\nPreviously tagged with (only expired)\n```ruby\nMyModel.previously_freeze_tagged(as: \"Fancy\")\n```\n\nEver tagged with (expired and unexpired)\n```ruby\nMyModel.ever_freeze_tagged(as: \"Fancy\")\n```\n\nAll the above methods work with a \"list\" argument as well\n```ruby\nMyModel.ever_freeze_tagged(as: \"Fancy\", list: \"Skills\")\n```\n\n#### Accessing the model directly.\n\n```ruby\nFreezeTag::Tag\n```\n\nWill give you direct access to the freeze tags table in a very standard way. \n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wework/freeze-tag. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the FreezeTag project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/freeze_tag/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwework%2Ffreeze-tag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwework%2Ffreeze-tag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwework%2Ffreeze-tag/lists"}