map メソッドの使用に関する理解が不足しています。
マッピングなしで json 出力を使用する
format.json { render :json => @categories }
次の出力が得られます
[{"created_at":"2012-10-20T01:16:35+11:00","id":1,"name":"bathroom renovations","updated_at":"2012-10-20T01:16:35+11:00"}]
マッピングでjsonを使用する
format.json { render :json => @categories.map(&:name) }
この出力が得られます
["bathroom renovations"]
出力を次のようにするにはどうすればよいですか
[{"id":"1","name":"bathroom renovations"}]