Skip to content
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

match_to supports arrays! #628

Merged
merged 2 commits into from Dec 6, 2014
Merged

match_to supports arrays! #628

merged 2 commits into from Dec 6, 2014

Conversation

subvertallchris
Copy link
Contributor

I've found myself wanting to use an array in match_to a few times, so this lets us do that. It accepts an array of nodes or IDs.

While not always the most efficient way of doing things, it lets you do things like this:

current_user.shows(:s, :r).rel_where(auth: 99).bands.match_to(other_user.bands.to_a).pluck(:s)

"Return current user's shows where their auth level is 99 and the bands playing include any of this other user's bands." n + 1, but fast and easy to write. In the future, I'd love to see if we could do this in a single query from QueryProxy.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling bb6fd9a on match_to-array into 27ffb20 on master.

subvertallchris added a commit that referenced this pull request Dec 6, 2014
@subvertallchris subvertallchris merged commit 6492a66 into master Dec 6, 2014
@cheerfulstoic
Copy link
Contributor

Awesome! ;p

@subvertallchris subvertallchris deleted the match_to-array branch December 11, 2014 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants