# heartcombo/has_scope

Map incoming controller parameters to named scopes in your resources

Repository: https://github.com/heartcombo/has_scope
Canonical: https://ross.abutalabs.com/products/has_scope
Language: Ruby
License: MIT
License Family: permissive
Last push: 2026-03-27T12:50:52+00:00

## Health v2 (maintenance only)
Score: 60/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 74, release rhythm 18, longevity 100
- inputs: {"age_days": 6116, "days_push": 159, "days_rel": 334, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1728, forks 92 (observed 2026-08-28T04:05:28.417555+00:00)

## What it is
HasScope is a Ruby gem that dynamically applies ActiveRecord named scopes to resources based on incoming controller parameters. It is most commonly used in Rails controllers to map request query parameters to safe, whitelisted scope-based filtering of records.

## Use cases
- filter Rails index listings by query params like ?featured=true
- map incoming controller parameters to named scopes safely
- build filterable resource endpoints without manual param parsing
- restrict which scopes a controller action may apply
- inspect currently applied scopes in controllers or views
- apply scopes to resources outside of controllers

## When to choose
- you have a Rails or Ruby app using ActiveRecord named scopes
- you want declarative, whitelisted param-to-scope filtering
- you need type coercion for boolean or hash scope parameters

## When to avoid
- you don't use ActiveRecord or named scopes
- you need complex filtering logic beyond simple scope mapping
- you're not on a Ruby/Rails stack

## Facets
- artifact type: library
- maturity: stable
- function: middleware, routing, database
- domain: web-development, backend, developer-tools
- platform: ruby
- tags: rails, active-record, named-scopes, filtering, query-parameters, gem, web-server

## Member repositories
- heartcombo/has_scope (main) score 60

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:28.417555+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:32:09.067685+00:00, confidence not recorded.
  - readme: https://github.com/heartcombo/has_scope (fetched 2026-08-28T04:05:28.417555+00:00, sha c94cbd667c2b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
