diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2010-01-03 22:02:10 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2010-01-03 22:02:10 -0500 |
commit | 532b11690fa2c4fd2c127ddc7df246c4469ebbc4 (patch) | |
tree | d6899fd71cda5b172cc588fd358ca76c08de11ae /activemodel | |
parent | 0422314b29e6b59362eb1111c983740784428b73 (diff) | |
download | rails-532b11690fa2c4fd2c127ddc7df246c4469ebbc4.tar.gz rails-532b11690fa2c4fd2c127ddc7df246c4469ebbc4.tar.bz2 rails-532b11690fa2c4fd2c127ddc7df246c4469ebbc4.zip |
Change the ActiveModel::Base.include_root_in_json default to true for Rails 3 [DHH]
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/CHANGELOG | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/serializers/json.rb | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/activemodel/CHANGELOG b/activemodel/CHANGELOG index 26500568ee..7489c0daa5 100644 --- a/activemodel/CHANGELOG +++ b/activemodel/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Change the ActiveModel::Base.include_root_in_json default to true for Rails 3 [DHH] + * Add validates_format_of :without => /regexp/ option. #430 [Elliot Winkler, Peer Allan] Example : 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 <tt>ActiveRecord::Base.include_root_in_json</tt> controls the - # top-level behavior of to_json. In a new Rails application, it is set to - # <tt>true</tt> in initializers/new_rails_defaults.rb. When it is <tt>true</tt>, + # The option <tt>ActiveModel::Base.include_root_in_json</tt> controls the + # top-level behavior of to_json. It is true by default. When it is <tt>true</tt>, # 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} } |