title: How to build a json object of a Mongoid object with children?
body: <p>I have two simple classes</p>
  
  <pre><code>class Band
    include Mongoid::Document
    field :name, type:String
    has_many :members
  end
  
  class Member
    include Mongoid::Document
    field :name, type: String
    belongs_to :band
  end
  </code></pre>
  
  <p>After I have created two object for test purposes</p>
  
  <pre><code>Band.create(title: 'New Band')
  Band.members.create(name: 'New Member')
  </code></pre>
  
  <p>I got next db state:</p>
  
  <pre><code>&gt; db.bands.find()
  { "_id" : ObjectId("..."), "title" : "New Band" }
  &gt; db.members.find()
  { "_id" : ObjectId("..."), "name" : "New Member", "band_id" : ObjectId("...") }
  </code></pre>
  
  <p>When I try to build json object of Band object I get data without children:</p>
  
  <pre><code>{"_id":"...","title":"New Band"}
  </code></pre>
  
  <p>But I need something like that:</p>
  
  <pre><code>{"_id":"...","title":"New Band", "members" : {"_id":"...","title":"New Member"}}
  </code></pre>
  
  <p>How to build json with children??</p>