Answer the question
In order to leave comments, you need to log in
How to sort out data from a database in Rails where the nesting level is unknown ???
Take, for example, the assistant manager. That is, each chief has his assistants, and in turn these assistants have their assistants, and so on.
For example, they have such a relationship Boss.id = Аssistant.boss_id (has_many, belongs_to - many to one).
So there is a boss with id = 5. And I need to take all the id-shniks of my assistants, including their assistants, and so on until the end.
And how to implement it if I don't know the levels???
Answer the question
In order to leave comments, you need to log in
the best solution would be to include the gem https://github.com/collectiveidea/awesome_nested_set
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question