{"id":19675275,"url":"https://github.com/opengems/rails_scopy","last_synced_at":"2025-10-06T09:30:30.209Z","repository":{"id":48155534,"uuid":"243636004","full_name":"OpenGems/rails_scopy","owner":"OpenGems","description":"Generate automatically scopes in your model (PostgreSQL, SQLite, MySQL, etc...)","archived":false,"fork":false,"pushed_at":"2023-03-31T14:09:25.000Z","size":27,"stargazers_count":8,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T15:10:04.143Z","etag":null,"topics":["activerecord","activerecord-extension","activerecord-models","activerecord-pattern","activerecord-queries","rails"],"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/OpenGems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-02-27T23:15:41.000Z","updated_at":"2023-05-09T01:13:15.000Z","dependencies_parsed_at":"2024-11-11T17:24:54.420Z","dependency_job_id":"0f011ac3-54a6-4b42-892b-97ac4f627eae","html_url":"https://github.com/OpenGems/rails_scopy","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"fb0878cc6dd62e9e73e4e14caa7eb09422fff737"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Frails_scopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Frails_scopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Frails_scopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Frails_scopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenGems","download_url":"https://codeload.github.com/OpenGems/rails_scopy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235515428,"owners_count":19002481,"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","activerecord-extension","activerecord-models","activerecord-pattern","activerecord-queries","rails"],"created_at":"2024-11-11T17:22:52.887Z","updated_at":"2025-10-06T09:30:29.842Z","avatar_url":"https://github.com/OpenGems.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RailsScopy\n\n[![Gem Version](https://badge.fury.io/rb/rails_scopy.svg)](https://badge.fury.io/rb/rails_scopy)\n[![Maintainability](https://api.codeclimate.com/v1/badges/79cdc15c16da15562c25/maintainability)](https://codeclimate.com/github/OpenGems/rails_scopy/maintainability)\n[![Build Status](https://travis-ci.org/OpenGems/rails_scopy.svg?branch=master)](https://travis-ci.org/OpenGems/rails_scopy)\n[![security](https://hakiri.io/github/OpenGems/rails_scopy/master.svg)](https://hakiri.io/github/OpenGems/rails_scopy/master)\n![Gem](https://img.shields.io/gem/dt/rails_scopy)\n[![Coverage Status](https://coveralls.io/repos/github/OpenGems/rails_scopy/badge.svg?branch=master)](https://coveralls.io/github/OpenGems/rails_scopy?branch=master)\n\nGenerate automatically scopes in your model (PostgreSQL, SQLite, MySQL, etc...)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rails_scopy'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rails_scopy\n\n## Usage\n\nInclude ```RailsScopy``` in each models\n\n```ruby\nclass User \u003c ApplicationRecord\n  include RailsScopy\nend\n```\n\nor in the parent model\n\n```ruby\nclass ApplicationRecord \u003c ActiveRecord::Base\n  include RailsScopy\nend\n```\n\nand\n\n```ruby\nUser.not_admin\n\nUser.first_name_contains('Test')\n```\n\n\n### Scopes available\n\n| SQL type | Scope method | Description |\n| ------------- | ------------- | ------------- |\n| All | `#{column}_eq(value)` | equal |\n| All | `#{column}_not_eq(value)` | not equal |\n| All | `#{column}_null` | is null |\n| All | `#{column}_not_null` | is not null |\n| All | `#{column}_present` | not null and not empty |\n| All | `#{column}_blank` | null or empty |\n| All | `ascend_by_#{column}` | ascending order |\n| All | `descend_by_#{column}` | descending order |\n| boolean | `#{column}` | true |\n| boolean | `not_#{column}` | false |\n| json | `#{column}_has_key(value)` | key present in json  |\n| json | `not_#{column}_has_not_key(value)` | key doesn't present in json |\n| boolean | `#{column}` | true |\n| boolean | `not_#{column}` | false |\n| date, datetime, time | `#{column}_to(value)` | \u003c= to  |\n| date, datetime, time | `#{column}_from(value)` | from \u003e= |\n| date, datetime, time | `#{column}_after(value)` | after \u003e |\n| date, datetime, time | `#{column}_before(value)` | \u003c before |\n| date, datetime, time | `#{column}_between(value)` | from \u003e= \u003c= to |\n| string, text | `#{column}_contains(value)` | contains |\n| string, text | `#{column}_not_contains(value)` | doesn't contains |\n| string, text | `#{column}_starts_with(value)` | start with |\n| string, text | `#{column}_not_starts_with(value)` | doesn't start with |\n| string, text | `#{column}_ends_with(value)` | end with |\n| string, text | `#{column}_not_ends_with(value)` | doesn't end with |\n| string, text | `#{column}_length(value)` | length eql |\n| string, text | `#{column}_between_length(value)` | from \u003e= \u003c= to (length) |\n| integer, float | `#{column}_to(value)` | \u003c= to  |\n| integer, float | `#{column}_from(value)` | from \u003e= |\n| integer, float | `#{column}_above(value)` | above \u003e |\n| integer, float | `#{column}_below(value)` | \u003c below |\n| integer, float | `#{column}_between(value)` | from \u003e= \u003c= to |\n| float | `#{column}_scale(value)` | scale eql (Number of decimal digits) |\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/OpenGems/rails_scopy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant 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).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopengems%2Frails_scopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopengems%2Frails_scopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopengems%2Frails_scopy/lists"}