Address concerns from #1018 commit c59668e

This commit is contained in:
Benjamin Fleischer
2016-02-08 17:55:15 -06:00
parent c59668e7a8
commit 5b953ff40f
5 changed files with 51 additions and 45 deletions

View File

@@ -103,7 +103,46 @@ PR please :)
#### links
PR please :)
##### How to add top-level links
JsonApi supports a [links object](http://jsonapi.org/format/#document-links) to be specified at top-level, that you can specify in the `render`:
```ruby
links_object = {
href: "http://example.com/api/posts",
meta: {
count: 10
}
}
render json: @posts, links: links_object
```
That's the result:
```json
{
"data": [
{
"type": "posts",
"id": "1",
"attributes": {
"title": "JSON API is awesome!",
"body": "You should be using JSON API",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
}
}
],
"links": {
"href": "http://example.com/api/posts",
"meta": {
"count": 10
}
}
}
```
This feature is specific to JsonApi, so you have to use the use the [JsonApi Adapter](adapters.md#jsonapi)
### serializer_opts