title: Mongoid Query Related Collection
body: <p>I'm trying to figure out how to query related collections in Mongoid.</p>
  
  <p>Here is my object model (simplified for brevity):</p>
  
  <pre><code>Category
  -------------------
  class Category
      include Mongoid::Document
  
      field :name, type: String
      ...
      belongs_to: product
  end
  
  class Product
     include Mongoid::Document
  
     field :name, type: String
     ...
     has_one :category
  end
  </code></pre>
  
  <p>I'm trying to build a query to get all products with category with a particular name e.g. "Toy"</p>
  
  <pre><code>products = Product.where('category.name' =&gt; 'Toy')
  </code></pre>
  
  <p>I get a nil collection back. I think mongoid does not support this types of queries directly. How do I build a query that will accomplish that?</p>