Skip to content

Commit

Permalink
Merge pull request #524 from depy/master
Browse files Browse the repository at this point in the history
Adds an example for using ArraySerializer under Render independently.
  • Loading branch information
arthurnn committed Mar 11, 2014
2 parents 289dfac + d9ff6db commit 3201c63
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3201c63

Please sign in to comment.