diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-02-28 19:44:25 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-02-28 19:44:25 +0000 |
commit | 0db6c3f51828e1a37e2c7b9245ffa8c12ac59c83 (patch) | |
tree | 6d4655e5982c7194f9c1a57f0a1d888cf93ad290 /activerecord | |
parent | 5029210914059faa65358b98a9c033a40e803c54 (diff) | |
download | rails-0db6c3f51828e1a37e2c7b9245ffa8c12ac59c83.tar.gz rails-0db6c3f51828e1a37e2c7b9245ffa8c12ac59c83.tar.bz2 rails-0db6c3f51828e1a37e2c7b9245ffa8c12ac59c83.zip |
Merge docrails and update the release notes
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/serializers/json_serializer.rb | 19 |
1 files changed, 19 insertions, 0 deletions
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 <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>, + # 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 + # <tt>false</tt>. + # # Without any +options+, the returned JSON string will include all # the model's attributes. For example: # |