From 358b6a88756e07e1fbf324e92fe9c40a72579ff9 Mon Sep 17 00:00:00 2001 From: David Verhasselt Date: Tue, 14 May 2013 10:42:28 +0300 Subject: [PATCH] Update README.md --- README.md | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ce244b4c..d870125d 100644 --- a/README.md +++ b/README.md @@ -141,10 +141,14 @@ render :json => @posts, :root => "some_posts" You may disable the root element for arrays at the top level, which will result in more concise json. To disable the root element for arrays, you have 4 options: -#### 1. Disable root globally for in `ArraySerializer`. In an initializer: +#### 1. Disable root globally for `ArraySerializer`. In an initializer: ```ruby ActiveSupport.on_load(:active_model_serializers) do + # Disabled for all serializers + # ActiveModel::Serializer.root = false + + # Or just for the ArraySerializer ActiveModel::ArraySerializer.root = false end ``` @@ -195,18 +199,6 @@ def default_serializer_options end ``` -## Disabling root globally - -If you want to disable the ```root```-node for all serializers, not just when -they are used in ```respond_with```, you can set the ```root``` option for the -main class in an initializer just like with Arrays: - -```ruby -ActiveSupport.on_load(:active_model_serializers) do - ActiveModel::Serializer.root = false -end -``` - ## Getting the old version If you find that your project is already relying on the old rails to_json