title: How to do a MondoID aggregation on related document
body: <p>I'm using MongoDB and MongoID. I have relationship of documents such as <code>has_many</code> between model <code>Campaign</code> and <code>Media</code> where <code>Campaign belongs_to Media</code>.</p>
  
  <p>I'd like to make an aggregation on Campaign where I get a value from Media. I'm trying the following:</p>
  
  <pre><code>results = Campaign.collection.aggregate [
      { '$match': { "state": 'active' } },
      { '$group': {
        '_id': { budget: "$media.budget", date: "$date" },
        'budget': { '$sum': { 'media': '$budget' } }
        }
      }
    ]
  </code></pre>
  
  <p>Where I'd like to get the total budget of Model Media which has a property called <code>budget</code>. The above is not working. Any idea on how to make it work?</p>