title: Finding nil has_one associations in where query
body: <p>This may be a simple question, but I seem to be pulling my hair out to find an elegant solution here. I have two ActiveRecord model classes, with a has_one and belongs_to association between them:</p>
  
  <pre><code>class Item &lt; ActiveRecord::Base
    has_one :purchase
  end
  
  class Purchase &lt; ActiveRecord::Base
    belongs_to :item
  end
  </code></pre>
  
  <p>I'm looking for an elegant way to find all Item objects, that have no purchase object associated with them, ideally without resorting to having a boolean <code>is_purchased</code> or similar attribute on the Item.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>purchases = Purchase.all
  Item.where('id not in (?)', purchases.map(&amp;:item_id))
  </code></pre>
  
  <p>Which works, but seems inefficient to me, as it's performing two queries (and purchases could be a massive record set).</p>
  
  <p>Running Rails 3.1.0</p>