{"id":20496476,"url":"https://github.com/hardpixel/active-similar","last_synced_at":"2025-04-13T18:21:19.221Z","repository":{"id":62559669,"uuid":"531939798","full_name":"hardpixel/active-similar","owner":"hardpixel","description":"Ruby gem to find similar Active Record models through most common associations.","archived":false,"fork":false,"pushed_at":"2022-09-05T16:36:09.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T21:09:49.686Z","etag":null,"topics":[],"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/hardpixel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["jonian"]}},"created_at":"2022-09-02T13:37:09.000Z","updated_at":"2022-09-06T16:59:59.000Z","dependencies_parsed_at":"2022-11-03T12:00:35.192Z","dependency_job_id":null,"html_url":"https://github.com/hardpixel/active-similar","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-similar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-similar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-similar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardpixel%2Factive-similar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardpixel","download_url":"https://codeload.github.com/hardpixel/active-similar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248759012,"owners_count":21157078,"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-11-15T18:07:17.472Z","updated_at":"2025-04-13T18:21:19.198Z","avatar_url":"https://github.com/hardpixel.png","language":"Ruby","readme":"# Active Similar\n\nRuby gem to find similar Active Record models through most common associations.\n\n[![Gem Version](https://badge.fury.io/rb/active_similar.svg)](https://badge.fury.io/rb/active_similar)\n[![Build](https://github.com/hardpixel/active-similar/actions/workflows/build.yml/badge.svg)](https://github.com/hardpixel/active-similar/actions/workflows/build.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/741c7fbb7ebb32bc0559/maintainability)](https://codeclimate.com/github/hardpixel/active-similar/maintainability)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_similar'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install active_similar\n\n## Usage\n\n```ruby\nrequire 'active_similar'\n\nclass Post \u003c ActiveRecord::Base\n  include ActiveSimilar\n\n  has_many :categories\n  has_many :tags\n\n  scope :published, -\u003e { where status: 'published' }\n  scope :featured,  -\u003e { where featured: true }\n\n  has_similar :related, through: %i[categories tags], scope: :published\nend\n\npost = Post.find(1)\npost.related # Returns similar posts to post #1\n\nsimilar = ActiveSimilar::Query.new(Post.published, through: %i[categories tags])\nsimilar.with(2) # Returns similar posts to post #2\n\nsimilar = ActiveSimilar::Query.new(Post.featured, through: %i[categories])\nsimilar.with(3) # Returns similar posts to post #3\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/active-similar.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":["https://github.com/sponsors/jonian"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardpixel%2Factive-similar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardpixel%2Factive-similar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardpixel%2Factive-similar/lists"}