ClosureTree/closure_tree
Easily and efficiently make your ActiveRecord models support hierarchies observed · 2026-08-28
Health v2 · maintenance only
97/100
- Activity 96
- Release rhythm 96
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: 30.0
- age_days: 5586
- days_rel: 28
- days_push: 28
- n_releases_24m: 11
Adoption not part of the score
1944 stars · 248 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
A Ruby gem that lets ActiveRecord models act as nodes in a tree data structure using the closure table pattern. It provides highly efficient single-query reads and writes for hierarchical data like tags, threaded comments, and CMS page graphs.
Use cases
- store hierarchical data like tags or categories in Rails
- model threaded comments with parent-child relationships
- fetch all descendants of a node in one query
- find or create a node by its ancestry path
- render tree structures as nested hashes or Graphviz DOT format
- manage user referral hierarchies
When to choose
- you use ActiveRecord 7.2+ and need performant tree queries
- you need fast ancestor/descendant/sibling lookups in a single SELECT
- you need concurrency-safe hierarchy mutations
- you want STI support within a hierarchy
When to avoid
- you are not using Ruby on Rails or ActiveRecord
- you need support for ActiveRecord versions older than 7.2
- your hierarchy is shallow and simple enough for a basic parent_id column
- you use a database other than MySQL, PostgreSQL, or SQLite
Facets
library · maturity active
orm database data-science databases web-development developer-tools ruby jvm activerecord closure-table tree-structure hierarchy rails nested-hashes ancestry nested-set
2 sources
- readme: https://github.com/ClosureTree/closure_tree · fetched 2026-08-28 · 51bb47e34d32
- homepage: http://closuretree.github.io/closure_tree/ · fetched 2026-08-29 · 4436b823ec60
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| ClosureTree/closure_tree | main | 97 |
For agents
markdown · JSON · MCP: product_card(name="ClosureTree/closure_tree")
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem