title: mongoid scope with referenced object as criteria
body: <p>I have following scope for Mongoid model in Rails 3:</p>
  
  <pre><code>class Expert
    include Mongoid::Document
    referenced_in :category
  
     scope :currently_available, lambda { |category, limit|
      limit ||= 5
      {
        :where =&gt; {:category =&gt; category, :state =&gt; 'available'}, 
        :limit =&gt; limit
      }
    }
  </code></pre>
  
  <p><code>category</code> here is an instance of referenced model:</p>
  
  <pre><code>class Category
    include Mongoid::Document
    references_many :experts, :inverse_of =&gt; :category
  </code></pre>
  
  <p>When I call the scope as <code>Expert.currently_available(Category.first, 5)</code>, I got a Criteria object:</p>
  
  <pre><code>ruby-1.9.2-p136 :110 &gt; Expert.currently_available(Category.first, 5)
   =&gt; #&lt;Mongoid::Criteria
    selector: {:category=&gt;#&lt;Category _id: 4d95ea8773fdea4c47000003, _type: nil, _id: BSON::ObjectId('4d95ea8773fdea4c47000003'), title: "Tax Advisors", price: 5.5&gt;, :state=&gt;"available"},
    options:  {:limit=&gt;5},
    class:    Expert,
    embedded: false&gt;
  </code></pre>
  
  <p><strong>Question is:</strong> How can I load a collection within this criteria? When I do <code>.to_a</code>, it says:<br>
  <code>Cannot serialize an object of class Category into BSON</code></p>
  
  <p>Category itself is valid BSON obj when picked up directly, but in scope it fails to render referencing obj.</p>
  
  <p>Thanks in advance!</p>