Skip to content
Advertisement

Rails – Relation passed to #or must be structurally compatible. Incompatible values: [:joins]

I’d like to merge two queries in my rails app. Each one is not very complex but I can’t merge them.

user.rb

package.rb

I’m running into this error:

Relation passed to #or must be structurally compatible. Incompatible values: [:joins]

Advertisement

Answer

I think what you’re looking for is a subselect:

This code should really be moved into the model instead of leaving all the wires hanging out:

An alternative method is using a union:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement