title: Automatically encode points to geojson with as_json in rails3
body: <p>A rails service I am currently working on requires that points are returned as a GeoJSON object within our json response. We are using rgeo and the mysql2spatial adapter to represent these points in our application and I would like to use the rgeo-geojson gem to handle the encoding if possible (we already use it to decode geojson on post).</p>
  
  <p>I am currently overwriting as_json with the following code to achieve this:</p>
  
  <pre><code>   def as_json(params)
       l = {:lat_lng =&gt; ::RGeo::GeoJSON.encode(lat_lng)}
       self.attributes.merge(l).as_json
     end
  </code></pre>
  
  <p>However this is not optimal as the root (eg object: {}) is missing. Is there a function to easily include it? (a lot of our models have a lat_lng associated, so I'd rather not hard code it).</p>
  
  <p>Any tips for a ruby/rails beginner would be greatly appreciated</p>