aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorTenzin Chemi <imechemi@gmail.com>2019-04-25 18:23:27 +0530
committerTenzin Chemi <imechemi@gmail.com>2019-05-13 15:35:50 +0530
commit42a3ec8fee56f0dd472112796fe1ed1f31091a7a (patch)
treebf086b39761d7cce2c776ee5f75c033ed2272d21 /activemodel
parentdbcaf9d157c9303d617a200e8c4b0832eb8af749 (diff)
downloadrails-42a3ec8fee56f0dd472112796fe1ed1f31091a7a.tar.gz
rails-42a3ec8fee56f0dd472112796fe1ed1f31091a7a.tar.bz2
rails-42a3ec8fee56f0dd472112796fe1ed1f31091a7a.zip
Improve doc for :root option in as_json() [ci skip]
Remove trailing whitespace [ci skip] Reword Root value should be string [ci skip]
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/serializers/json.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/serializers/json.rb b/activemodel/lib/active_model/serializers/json.rb
index f77fb98c32..09dcae889b 100644
--- a/activemodel/lib/active_model/serializers/json.rb
+++ b/activemodel/lib/active_model/serializers/json.rb
@@ -42,6 +42,13 @@ module ActiveModel
# # => { "user" => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
# # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true } }
#
+ # If you prefer, <tt>:root</tt> may also be set to a custom string key instead as in:
+ #
+ # user = User.find(1)
+ # user.as_json(root: "author")
+ # # => { "author" => { "id" => 1, "name" => "Konata Izumi", "age" => 16,
+ # # "created_at" => "2006-08-01T17:27:13.000Z", "awesome" => true } }
+ #
# Without any +options+, the returned Hash will include all the model's
# attributes.
#