Skip to content

Commit b55fc32

Browse files
committed
improve doc as suggested by @bf4
1 parent 37e4f1c commit b55fc32

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/howto/add_top_level_links.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
JsonApi supports a [links object](http://jsonapi.org/format/#document-links) to be specified at top-level, that you can specify in the `render`:
44

55
```ruby
6-
render json: @posts, links: { "self": "http://example.com/api/posts" }
6+
links_object = {
7+
href: "http://example.com/api/posts",
8+
meta: {
9+
count: 10
10+
}
11+
}
12+
render json: @posts, links: links_object
713
```
814

915
That's the result:
@@ -23,7 +29,10 @@ That's the result:
2329
}
2430
],
2531
"links": {
26-
"self": "http://example.com/api/posts"
32+
"href": "http://example.com/api/posts",
33+
"meta": {
34+
"count": 10
35+
}
2736
}
2837
}
2938
```

0 commit comments

Comments
 (0)