title: Insert an array of Ruby objects in a Mongo database
body: <p>So, I'm using the Ruby MongoDB driver and I want to insert and object like this:</p>
  
  <pre><code> db.insert_one({
    'game_id' =&gt; @token,
    'board' =&gt; {
      'tiles' =&gt; @board.tiles
    }
  })
  </code></pre>
  
  <p>where @board is an instance of a Board class.</p>
  
  <pre><code>class Board
   attr_accessor :tiles
    def initialize()
      @tiles = [Tile.new, Tile.new]
    end
  end
  </code></pre>
  
  <p>and Tile</p>
  
  <pre><code>class Tile
    def initialize()
      @x = 1, @y = 1
    end
    def to_json(options)
      {"x" =&gt; @x, "y" =&gt; @y}.to_json
    end
  end
  </code></pre>
  
  <p>So at the end, 'tiles' field should look like this:</p>
  
  <pre><code>'tiles': [{x:1, y:1}, {x:1, y:1}]
  </code></pre>
  
  <p>I'm getting this error: </p>
  
  <pre><code>undefined method `bson_type' for #&lt;Tile:0x007ff7148d2440&gt;
  </code></pre>
  
  <p>The gems I'm using: 'sinatra', 'mongo (2.0.4)' and 'bson_ext' (all required using Bundler.require). Thanks!</p>