Skip to content

Commit

Permalink
Merge pull request #1201 from hut8/master
Browse files Browse the repository at this point in the history
Add documentation about wildcard includes
  • Loading branch information
beauby committed Oct 2, 2015
2 parents 34d6571 + a32ad43 commit 0669901
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,26 @@ resources in the `"included"` member when the resource names are included in the
render @posts, include: 'author,comments,comments.author'
```

In addition, two types of wildcards may be used. `*` includes one level of associations, and `**` includes all recursively. These can be combined with other paths.

```ruby
render @posts, include: '**' # or '*' for a single layer
```

The following would render posts and include the author, the author's comments, and every resource referenced by the author's comments (recursively). It could be combined, like above, with other paths in any combination desired.

```ruby
render @posts, include: 'author.comments.**'
```

The JSON API [specifies](http://jsonapi.org/format/#fetching-includes) that the user may supply a parameter specifying which related resources are to be included:

```ruby
render @posts, include: params[:include]
```

This raises some security concerns since the user could pass in `include=**`, so filter the values for `include` appropriately if you decide to support this JSON API feature.

## Installation

Add this line to your application's Gemfile:
Expand Down

0 comments on commit 0669901

Please sign in to comment.