This project is archived and is in readonly mode.

#3770 ✓resolved
Cody Fauser

[PATCH] Fix changing ActiveModel include_root_in_json = true to default

Reported by Cody Fauser | January 22nd, 2010 @ 01:06 PM | in 3.0.2

This commit was intended to change the default include_root_in_json setting to true. However, it contained an error and didn't actually set the default to true.

The following IRB session illustrates the issue:

ActiveRecord::Base.include_root_in_json
=> nil
irb(main):002:0> a = Article.new(:title => "AWDWR")
=> #<Article id: nil, title: "AWDWR", created_at: nil, updated_at: nil>
irb(main):003:0> puts a.to_json
{"created_at":null,"title":"AWDWR","updated_at":null}
=> nil
irb(main):004:0> ActiveRecord::Base.include_root_in_json = true
=> true
irb(main):005:0> puts a.to_json
{"article":{"created_at":null,"title":"AWDWR","updated_at":null}}
=> nil

A patch is attached.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages