From 55042937765258aeadac693752ea8534ec15bf7b Mon Sep 17 00:00:00 2001 From: David Verhasselt Date: Mon, 13 May 2013 18:23:20 +0300 Subject: [PATCH] Update README.md I'm a bit embarrassed to admit that it took me a while to figure out this was a possibility, so I figured maybe this change will save some other poor chaps their time and/or pride. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 7e92976b..ce244b4c 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,18 @@ 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