# ErwinM/acts_as_tenant

Easy multi-tenancy for Rails in a shared database setup.

Repository: https://github.com/ErwinM/acts_as_tenant
Canonical: https://ross.abutalabs.com/products/acts_as_tenant
Language: Ruby
License: MIT
License Family: permissive
Last push: 2025-04-16T14:18:59+00:00

## Health v2 (maintenance only)
Score: 30/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 16, release rhythm 8, longevity 100
- inputs: {"age_days": 5504, "days_push": 504, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1701, forks 267 (observed 2026-08-28T04:05:24.219754+00:00)

## What it is
A Ruby gem that adds fail-safe row-level multi-tenancy to Ruby on Rails applications using a shared database. It scopes models to a current tenant (e.g., an Account), sets the tenant per request via subdomain or controller, and guards against tenant-scoping bypasses.

## Use cases
- add multi-tenancy to a Rails app with a shared database
- scope all ActiveRecord models to the current tenant automatically
- resolve the current tenant from the request subdomain
- validate record uniqueness within a tenant
- prevent users from accessing another tenant's data

## When to choose
- you're building a Rails app with a shared database and row-level tenancy
- you want automatic, fail-safe tenant scoping with minimal code changes
- you identify tenants by subdomain or per-request logic

## When to avoid
- you need schema-based multitenancy (consider the Apartment gem)
- you're not using Rails or ActiveRecord
- you need database-per-tenant isolation

## Facets
- artifact type: library
- maturity: active
- function: middleware, database, security
- domain: web-development, backend, developer-tools
- platform: ruby
- tags: rails, multi-tenancy, row-level-tenancy, shared-database, gem, activerecord, web-server

## Member repositories
- ErwinM/acts_as_tenant (main) score 30

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:24.219754+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:37:41.932828+00:00, confidence not recorded.
  - readme: https://github.com/ErwinM/acts_as_tenant (fetched 2026-08-28T04:05:24.219754+00:00, sha 2ffcb1410a5c)
- Data as of 2026-08-30T08:39:29.467469+00:00.
