From 0db6c3f51828e1a37e2c7b9245ffa8c12ac59c83 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 28 Feb 2009 19:44:25 +0000 Subject: Merge docrails and update the release notes --- .../lib/active_record/serializers/json_serializer.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/serializers/json_serializer.rb b/activerecord/lib/active_record/serializers/json_serializer.rb index 419b45d475..1fd65ed006 100644 --- a/activerecord/lib/active_record/serializers/json_serializer.rb +++ b/activerecord/lib/active_record/serializers/json_serializer.rb @@ -8,6 +8,25 @@ module ActiveRecord #:nodoc: # 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, + # 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} } + # + # ActiveRecord::Base.include_root_in_json = false + # konata.to_json + # # => {"id": 1, "name": "Konata Izumi", "age": 16, + # "created_at": "2006/08/01", "awesome": true} + # + # The remainder of the examples in this section assume include_root_in_json is set to + # false. + # # Without any +options+, the returned JSON string will include all # the model's attributes. For example: # -- cgit v1.2.3