From e138ea42767ca117faa5b90ab721982713812749 Mon Sep 17 00:00:00 2001 From: Jonathan Richard Henry Evans Date: Mon, 9 Sep 2013 13:09:51 +0100 Subject: [PATCH] Updated readme as to new root behaviour --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index feecbff..32a774a 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,24 @@ end ``` In this case, as User objects are being returned, grape-active_model_serializers will look for a serializer named UserSerializer. +### Array roots +When serializing an array, the array root is set to the innermost namespace name if there is one, otherwise it is set to the route name (e.g. get 'name') + +```ruby +namespace :users do + get ":id" do + @user = User.find(params[:id]) + end +end +# root = users +``` + +```ruby +get "people" do + @user = User.all +end +# root = people +``` ### Manually specifying serializer options