[Feature] scopes for multiple nodes #127

Open
ismaelga opened this Issue Apr 11, 2013 · 0 comments

Comments

Projects
None yet
1 participant

Sometimes you need to get all the descendants for multiple nodes. The way to do it now would be something like: (Using the scopes)

all_descendants = model_ids.map { | id |
  Model.descendants_of(id)
}.flatten

My suggestion is that the scopes, or at least some of them, can handle multiple nodes or nodes ids, so we can do something like this

all_descendants = Model.descendantes_of(models_ids)

This way is away better since it reduces the queries made and also we get an ActiveRecord relation instead of an array.

I created this issue to get some feedback on how this can be useful for others or not. I might send a pull request for this on the next weeks if this looks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment