Relation passed to #or must be structurally compatible. Incompatible values: [:references]
<p>I have two queries, I need an <code>or</code> between them, i.e. I want results that are returned by either the first or the second query.</p>

<p>First query is a simple <code>where()</code> which gets all available items.</p>

<pre><code>@items = @items.where(available: true)
</code></pre>

<p>Second includes a <code>join()</code> and gives the current user's items.</p>

<pre><code>@items =
  @items
  .joins(:orders)
  .where(orders: { user_id: current_user.id})
</code></pre>

<p>I tried to combine these with Rails' <code>or()</code> method in various forms, including:</p>

<pre><code>@items =
  @items
  .joins(:orders)
  .where(orders: { user_id: current_user.id})
  .or(
    @items
    .joins(:orders)
    .where(available: true)
  )
</code></pre>

<p>But I keep running into this error and I'm not sure how to fix it.</p>

<pre><code>Relation passed to #or must be structurally compatible. Incompatible values: [:references]
</code></pre>