New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] scopes for multiple nodes #127

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

Comments

Projects
None yet
1 participant
@ismaelga

ismaelga commented Apr 11, 2013

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