Unfortunately the use of multiple arguments to joins() is already taken - to pass multiple different joins.
I think this was particularly intended for the case where the arguments to joins() are association names -
Document.joins(:authors, :votes)
But unfortunately it is also supported for SQL strings
Document.joins(“JOIN tableA ON foo”, “JOIN tableB on bar”)
I personally feel that we could live without that for the string joins case, because of course you could always just combine the two strings together and achieve the same effect.
But it is a backwards-incompatible change, which always makes it a bit harder to get through, and the code may be a little ugly since you still need to interpret multiple symbols in a different way for the other case.
Personally I’d actually like to see the use of scopes here instead. To avoid the above argument dilemma, we could provide them using a block to the joins() method:
Document.
joins(:votes) { where(“extra join conditions to add to the ON clause go here”) }.
where(…).
to_a
For a standard join this is no different to merging the scope into the query relation, so we wouldn’t bother just for that.
But, we could then add a left_joins() method, and that would then solve exactly the case you described - but it would also allow us to reuse existing associations and scopes without having to drop down to manually writing out SQL. That would be a huge win for me!