From 30c509dbbb301d9fa2b7d15324eeed59734f7fa8 Mon Sep 17 00:00:00 2001 From: Timur Date: Fri, 17 Mar 2017 22:53:14 +0600 Subject: [PATCH] Add docs for `include` option in the adapter --- docs/general/adapters.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/general/adapters.md b/docs/general/adapters.md index 6ae1d27a5..dd86e9031 100644 --- a/docs/general/adapters.md +++ b/docs/general/adapters.md @@ -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: