You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def self.subtree_ids_for roots
roots.map{ | r | r.subtree_ids}.flatten.uniq
end
def self.subtrees_for roots
self.where(id: self.subtree_ids_for(roots))
end
Activity
markmoser commentedon Aug 20, 2013
like this?
is there a better way to do this?
kbrock commentedon May 2, 2018
Believe it or not, still working on this one.
Hoping I'm close.
nflorentin commentedon May 17, 2019
Rails 5 added support for "or" queries, so it could be something like that using only 2 queries:
But I think there is a more elegant way to write it...
kbrock commentedon May 21, 2019
@nflorentin yes, using ActiveRecord
orwould get rid of a bunch of arel helpers.I'm thinking the next major version of ancestry will probably drop older versions of active record that do not support
or.