E
E
eldar_web2015-09-01 10:46:24
Ruby on Rails
eldar_web, 2015-09-01 10:46:24

How to recurse data from a database in Rails?

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

1 answer(s)
B
Boris Penkovsky, 2015-09-01
@Able1991

https://github.com/collectiveidea/awesome_nested_set for helpers model

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question