Skip to content

Commit

Permalink
Add docs for include option in the adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-wasp committed Mar 17, 2017
1 parent 01d4f04 commit 30c509d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/general/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,19 @@ This adapter follows **version 1.0** of the [format specified](../jsonapi/schema
}
```

#### Included
### Include option

It will include the associated resources in the `"included"` member
when the resource names are included in the `include` option.
Including nested associated resources is also supported.
All built-in adapters allow to include the associated resources. Nested associated resources is also supported.
Use `include` option for this:

```ruby
render json: @posts, include: ['author', 'comments', 'comments.author']
# or
render json: @posts, include: 'author,comments,comments.author'
```
**Note:** Serializer classes must declare associations explicitly, using `belongs_to` and `has_many` and etc., for `include` option to work.

For JSON API adapter associated resources will be gathered in the `"included"` member.

In addition, two types of wildcards may be used:

Expand Down

0 comments on commit 30c509d

Please sign in to comment.