diff options
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/serializers/json.rb | 7 |
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. # |