title: Rails 3 - returning JSON objects wrapped in a single object?
body: <p>I currently have a controller that returns JSON objects, that looks like this:</p>
  
  <pre><code>def getModels
    @vehicleModels = @vehicleModels.where(:vehicleMake_id =&gt; params[:vehicleMake])
    respond_with(@vehicleModels)
  end
  </code></pre>
  
  <p>This works fine, and returns the following JSON:</p>
  
  <pre><code>[
  {"created_at":"2011-06-22T15:49:06Z","id":1,"name":"A4","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":2,"name":"A5","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":3,"name":"A6","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":4,"name":"A8","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":5,"name":"TT","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":10,"name":"Touareg","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1}
  ]
  </code></pre>
  
  <p>The problem is that the JQuery dropdown I am trying to load the JSON into seems to be expecting a JSON root node. As such, loading the JSON above directly does not work. But if it has a root node, as follows, it works fine:</p>
  
  <pre><code>{"results":[
  {"created_at":"2011-06-22T15:49:06Z","id":1,"name":"A4","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":2,"name":"A5","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":3,"name":"A6","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":4,"name":"A8","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":5,"name":"TT","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1},
  {"created_at":"2011-06-22T15:49:06Z","id":10,"name":"Touareg","updated_at":"2011-06-22T15:49:06Z","vehicleMake_id":1}
  ]}
  </code></pre>
  
  <p>So the question is a simple one - how can I get rails to include a root node?</p>
  
  <p>I should point out that I have attempted to do this by setting <code>ActiveRecord::Base.include_root_in_json = true</code> in my config, but that only added root nodes to each individual object, not one overall root node as I require.</p>
  
  <p>Thanks!</p>