{"id":26197296,"url":"https://github.com/mongoid/mongoid-tag-collectible","last_synced_at":"2025-04-15T03:55:41.005Z","repository":{"id":9160991,"uuid":"10957022","full_name":"mongoid/mongoid-tag-collectible","owner":"mongoid","description":"Easily maintain a collection of Tag instances with aggregate counts from your model's tags.","archived":false,"fork":false,"pushed_at":"2016-08-04T20:09:16.000Z","size":36,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T03:55:36.096Z","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/mongoid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-26T03:14:46.000Z","updated_at":"2021-11-08T10:12:46.000Z","dependencies_parsed_at":"2022-09-10T05:40:47.129Z","dependency_job_id":null,"html_url":"https://github.com/mongoid/mongoid-tag-collectible","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-tag-collectible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-tag-collectible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-tag-collectible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongoid%2Fmongoid-tag-collectible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongoid","download_url":"https://codeload.github.com/mongoid/mongoid-tag-collectible/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003952,"owners_count":21196794,"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":"2025-03-12T02:25:32.269Z","updated_at":"2025-04-15T03:55:40.988Z","avatar_url":"https://github.com/mongoid.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mongoid::TagCollectible\n=======================\n\n[![Gem Version](http://img.shields.io/gem/v/mongoid-tag-collectible.svg)](http://badge.fury.io/rb/mongoid-tag-collectible)\n[![Build Status](http://img.shields.io/travis/mongoid/mongoid-tag-collectible.svg)](https://travis-ci.org/mongoid/mongoid-tag-collectible)\n[![Dependency Status](https://gemnasium.com/mongoid/mongoid-tag-collectible.svg)](https://gemnasium.com/mongoid/mongoid-tag-collectible)\n[![Code Climate](https://codeclimate.com/github/mongoid/mongoid-tag-collectible.svg)](https://codeclimate.com/github/mongoid/mongoid-tag-collectible)\n\nEasily maintain a collection of `Tag` instances with aggregate counts from your model's `tags`.\n\n### Compatibility\n\nThis gem supports Mongoid 3, Mongoid 4 and Mongoid 5.\n\n### Install\n\nAdd `mongoid-tag-collectible` to your Gemfile.\n\n```\ngem 'mongoid-tag-collectible'\n```\n\n### Use\n\n``` ruby\nclass Thing\n  include Mongoid::Document\n  include Mongoid::TagCollectible::Tagged\nend\n\nthing1 = Thing.create!(tags: [ 'funny', 'red' ])\nthing2 = Thing.create!(tags: [ 'funny', 'yellow' ])\n\nfunny_tag = ThingTag.find('funny') # find by tag\nfunny_tag.name # \"funny\"\nfunny_tag.count # 2, not a database query\nfunny_tag.tagged # thing1 and thing2\n```\n\n#### Renaming Tags\n\nYou can rename a tag, which causes all the tags in your model's `tags` collection to be renamed.\n\n``` ruby\nThingTag.find('funny').update_attributes!(name: 'sad')\n\nThing.first.tags # [ 'sad', 'red' ]\n```\n\n#### Destroying Tags\n\nYou can destroy a tag, which also removes it from your model's `tags` collection.\n\n``` ruby\nThingTag.find('red').destroy\nThing.first.tags # [ 'sad' ]\n```\n\n#### Case-Sensitive\n\nTags are case-sensitive. Transform your tags in `before_validation` if you don't want this behavior.\n\n``` ruby\nclass Thing\n  before_validation :downcase_tags\n\n  private\n\n  def downcase_tags\n    tags = tags.map(\u0026:downcase) if tags\n  end\nend\n```\n\n### Contribute\n\nSee [CONTRIBUTING](CONTRIBUTING.md).\n\n### Copyright and License\n\nCopyright Daniel Doubrovkine and Contributors, Artsy Inc., 2013-2015\n\n[MIT License](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoid%2Fmongoid-tag-collectible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongoid%2Fmongoid-tag-collectible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongoid%2Fmongoid-tag-collectible/lists"}