title: Formatting JSON output using map method - Rails 3
body: <p>I'm lacking some understanding on using the map method. </p>
  
  <p>Using json output with no mapping</p>
  
  <pre><code>format.json  { render :json =&gt; @categories }
  </code></pre>
  
  <p>gives me the following output</p>
  
  <pre><code>[{"created_at":"2012-10-20T01:16:35+11:00","id":1,"name":"bathroom renovations","updated_at":"2012-10-20T01:16:35+11:00"}]
  </code></pre>
  
  <p>using json with mapping</p>
  
  <pre><code>format.json  { render :json =&gt; @categories.map(&amp;:name) }
  </code></pre>
  
  <p>gives me this output</p>
  
  <pre><code>["bathroom renovations"]
  </code></pre>
  
  <p>How can I get my output to look like</p>
  
  <pre><code>[{"id":"1","name":"bathroom renovations"}]
  </code></pre>