Skip to main content

How do I create hierarchical data with a model?

General • Asked by Félix Landry-Audet

I have found and played with awesome_nested_set which is awesome for real. I was wondering if this is the recommended gem for managing tree data in Rails or if there are any others that would do it. awesome_nested_set is really doing the job however I find it lacks of documentation.

Thanks! :)

Félix


There are a handful of different ways you can do it. This is actually a nice little blog post talking about 3 options and their pros / cons. Generally you're going to want ones with fast reads because that's going to be the more common query.

https://www.leighhalliday.com/tree-structures-in-your-rails-models


Yep thanks I read that. I was confident using awesome-nested_set but just found out closure_tree which seems to have more documentation and more options. I'll try it out.

Thanks!


Oh wonderful, I haven't heard of that one and by the docs and activity it certainly looks like it's well maintained. I'll have to try it out!


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.