From d9ff6db36d79080032c06a53ec8ea72b548f6f49 Mon Sep 17 00:00:00 2001 From: Matjaz Muhic Date: Thu, 6 Mar 2014 19:53:24 +0100 Subject: [PATCH] Adds an example for using ArraySerializer under Render independently. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 6263d879..03a0a9b6 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,15 @@ def current_user_as_json_helper end ``` +You can also render an array of objects using ArraySerializer. + +```ruby +def users_array_as_json_helper(users) + ActiveModel::ArraySerializer.new(users, each_serializer: UserSerializer).to_json +end +``` + + ## Disabling the root element You have 4 options to disable the root element, each with a slightly different scope: