Nested Records


Ancestry allows the records of a ActiveRecord model to be organized in a tree structure, using the materialized path pattern. It exposes the standard relations (ancestors, parent, root, children, siblings, descendants) and allows them to be fetched in a single query. Additional features include named scopes, integrity checking, integrity restoration, arrangement of (sub)tree into hashes and different strategies for dealing with orphaned records.

ancestry 9,934,338 Downloads Last release

stefankroes/ancestry Last commit


Easily and efficiently make your ActiveRecord model support hierarchies

closure_tree 2,070,797 Downloads Last release

mceachen/closure_tree Last commit


A gem that adds simple support for organizing ActiveRecord models into parent–children relationships.

acts_as_tree 5,393,295 Downloads Last release


Want to stay up-to-date with Ruby on Rails?

Join 66,029+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.