From 532b11690fa2c4fd2c127ddc7df246c4469ebbc4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 3 Jan 2010 22:02:10 -0500 Subject: Change the ActiveModel::Base.include_root_in_json default to true for Rails 3 [DHH] --- activemodel/lib/active_model/serializers/json.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/serializers/json.rb b/activemodel/lib/active_model/serializers/json.rb index ee6d48bfc6..794de7dc55 100644 --- a/activemodel/lib/active_model/serializers/json.rb +++ b/activemodel/lib/active_model/serializers/json.rb @@ -10,19 +10,17 @@ module ActiveModel included do extend ActiveModel::Naming - cattr_accessor :include_root_in_json, :instance_writer => false + cattr_accessor :include_root_in_json, :instance_writer => true end # Returns a JSON string representing the model. Some configuration is # available through +options+. # - # The option ActiveRecord::Base.include_root_in_json controls the - # top-level behavior of to_json. In a new Rails application, it is set to - # true in initializers/new_rails_defaults.rb. When it is true, + # The option ActiveModel::Base.include_root_in_json controls the + # top-level behavior of to_json. It is true by default. When it is true, # to_json will emit a single root node named after the object's type. For example: # # konata = User.find(1) - # ActiveRecord::Base.include_root_in_json = true # konata.to_json # # => { "user": {"id": 1, "name": "Konata Izumi", "age": 16, # "created_at": "2006/08/01", "awesome": true} } -- cgit v1.2.3