rails/rails — Issue #5063: ActiveResource::Base.include_root_in_json = false includes root
Author: southdesign
Created: 2012-02-16 14:27:50+00:00
State: open

I added `ActiveResource::Base.include_root_in_json = false` in the `application.rb`.

> rails c
> ActiveResource::Base.include_root_in_json
=> false

Team is an ActiveResource Model.

JSON Output is:

> Team.first.to_json
=> "{\"team\":{\"created_at\":\"2012-02-14T15:32:50Z\",\"id\":108,\"name\":\"Team A\",\"organization_id\":11,\"setting_ids\":null,\"updated_at\":\"2012-02-14T15:32:50Z\"}}"

JSON Output should be:

> Team.first.to_json
=> "{\"created_at\":\"2012-02-14T15:32:50Z\",\"id\":108,\"name\":\"Team A\",\"organization_id\":11,\"setting_ids\":null,\"updated_at\":\"2012-02-14T15:32:50Z\"}"

System Info:

rails -v
Rails 3.2.1

ruby -v
ruby 1.9.3p27 (2012-01-17 revision 34327) [x86_64-darwin11.2.0]