I have two queries, I need or between them, that is, I want the results to be returned either by the first or second query.
The first request is a simple where() method that gets all the available elements.
@items = @items.where(available: true)
The second includes join() and gives the current user elements.
@items = @items .joins(:orders) .where(orders: { user_id: current_user.id})
I tried combining them with the Rails or() method in various forms, including:
@items = @items .joins(:orders) .where(orders: { user_id: current_user.id}) .or( @items .joins(:orders) .where(available: true) )
But I continue to encounter this error, and I am not sure how to fix it.
Relation passed to #or must be structurally compatible. Incompatible values: [:references]
source share