Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with nested included association example. #1149

Merged

Conversation

mattmueller
Copy link
Contributor

Spent some time scratching my head today until I found out this was possible.

Hopefully including the example in the docs will save folks some time in the future when they come across the need to include nested associations.

@NullVoxPopuli
Copy link
Contributor

looks good! 👍

NullVoxPopuli added a commit that referenced this pull request Sep 14, 2015
…udes

Update README with nested included association example.
@NullVoxPopuli NullVoxPopuli merged commit 1ac82a1 into rails-api:master Sep 14, 2015
@mattmueller
Copy link
Contributor Author

👍

@bacarini
Copy link
Contributor

It is missing that doc on https://github.com/rails-api/active_model_serializers/blob/master/docs/general/adapters.md.

Could you include it there as well?


```ruby
render @posts, include: ['authors', 'comments']
render @posts, include: ['author', 'comments', 'comments.author']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to include as well a hash example, like [:author, comments: [:author]].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be nice to have written somewhere that including comments.author will automatically include the comments (i.e. all resources on a nested path will be included). At least, it is the case with the JsonApi adapter (the spec requires full linkage), but it would probably be good to enforce it on all adapters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's how it works on the json adapter, too. I thought it would be implied.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs should at least mention it I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants