{"id":19711712,"url":"https://github.com/brightcommerce/attr_array","last_synced_at":"2025-04-29T18:30:45.883Z","repository":{"id":65599514,"uuid":"109665023","full_name":"brightcommerce/attr_array","owner":"brightcommerce","description":"A high performance concern for Rails using the PostgreSQL array type.","archived":false,"fork":false,"pushed_at":"2017-11-23T13:08:16.000Z","size":6,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T05:22:35.426Z","etag":null,"topics":["activerecord","activesupport","array","concern","postgresql","tags"],"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/brightcommerce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-06T08:03:10.000Z","updated_at":"2019-01-07T01:20:04.000Z","dependencies_parsed_at":"2023-01-31T07:05:10.599Z","dependency_job_id":null,"html_url":"https://github.com/brightcommerce/attr_array","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/brightcommerce%2Fattr_array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brightcommerce","download_url":"https://codeload.github.com/brightcommerce/attr_array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251559727,"owners_count":21609063,"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":["activerecord","activesupport","array","concern","postgresql","tags"],"created_at":"2024-11-11T22:13:29.969Z","updated_at":"2025-04-29T18:30:45.589Z","avatar_url":"https://github.com/brightcommerce.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AttrArray\n\nA high performance ActiveRecord concern for Rails using the PostgreSQL array type.\n\n## Installation\n\nTo install add the line to your Gemfile:\n\n```ruby\ngem 'attr_array'\n```\n\nAnd `bundle install`.\n\n## Dependencies\n\nAttrArray is developed as a ActiveRecord model concern, therefore it is dependent upon ActiveSupport. It is also developed only for use with PostgreSQL. It may work with other databases, but I haven't tried them.\n\n## How To Use\n\nTo add AttrArray to a model, include the concern:\n\n```ruby\nclass Post \u003c ActiveRecord::Base\n  include AttrArray\n\n  attr_array :tags\nend\n```\n\nTo autoload AttrArray for all models, add the following to an initializer:\n\n```ruby\nrequire 'attr_array/active_record'\n```\n\nYou then don't need to `include AttrArray` in any model.\n\n### Scopes\n\n```ruby\nwith_any_#{tag_name}\nwith_all_#{tag_name}\nwithout_any_#{tag_name}\nwithout_all_#{tag_name}\n```\n\n### Class methods\n\n```ruby\nall_#{tag_name}\n{tag_name}_cloud\n```\n\n### Setup\n\nAdd the model attributes you want to use with AttrArray in your migration:\n\n```ruby\nclass CreatePost \u003c ActiveRecord::Migration[5.1]\n  def change\n    create_table :posts do |table|\n      table.column :tags, :string, array: true, default: [], index: {using: 'gin'}\n      table.column :authors, :string, array: true, default: [], index: {using: 'gin'}\n      table.timestamps\n    end\n  end\nend\n```\n\nYou can nominate multiple attributes in the `attr_array` class method:\n\n```ruby\nclass Post \u003c ApplicationRecord\n  include AttrArray\n\n  attr_array :tags, :authors\nend\n```\n\n### Usage\n\n```ruby\n@post.tags = [\"awesome\", \"slick\"]\n@post.authors = [\"Roald Dahl\"]\n\nPost.with_any_authors(\"Roald Dahl\")\nPost.without_any_tags(\"slick\")\n```\n\n## Acknowledgements\n\nThis gem is based on code from [pg_tags](https://github.com/yosriady/pg_tags). Modified to use ActiveSupport::Concern and doesn't automatically hook into ActiveRecord.\n\nThis gem is maintained by [Jurgen Jocubeit](https://github.com/JurgenJocubeit).\n\n## Copyright\n\nCopyright 2017 Brightcommerce, Inc. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightcommerce%2Fattr_array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightcommerce%2Fattr_array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightcommerce%2Fattr_array/lists"}