ClosureTree/closure_tree: Easily and efficiently make your ActiveRecord models support hierarchies

12-Jun-2025 40
Dramatically more performant than ancestry and acts_as_tree, and even more awesome than awesome_nested_set, closure_tree has some great features: Best-in-class select performance: Fetch your whole ancestor lineage in 1 SELECT. Grab all your descendants in 1 SELECT. Get all your siblings in 1 SELECT. Fetch all descendants as a nested hash in 1 SELECT. Find a node by ancestry path in 1 SELECT. Best-in-class mutation performance: 2 SQL INSERTs on node creation 3 SQL INSERT/UPDATEs on node reparenting.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle