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 ember-and-json-api.md #1894

Merged
merged 3 commits into from
Sep 7, 2016
Merged

Update ember-and-json-api.md #1894

merged 3 commits into from
Sep 7, 2016

Conversation

Ikariusrb
Copy link
Contributor

Purpose

Update the ember integration documentation

Changes

Update documentation for how to get ember to use include directives
Add documentation on how to update controllers to tell Rails we are consuming and generating jsonapi data.

Caveats

Related GitHub issues

Additional helpful information

Removed ember-data adapter change to support include directives, as it's now built-in. Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data

Removed ember-data adapter change to support include directives, as it's now built-in.  Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data
@mention-bot
Copy link

@Ikariusrb, thanks for your PR! By analyzing the annotation information on this pull request, we identified @NullVoxPopuli, @kyleshevlin and @bf4 to be potential reviewers


```ruby
# config/initializers/active_model_serializers.rb
require 'active_model_serializers/register_jsonapi_renderer'
```
Rails also requires your controller to tell it that you accept and generate JSONAPI data. To do that, you use `respond_to` in your controller handlers. You can add `ActionController::MimeResponds` to your application controller to enable this:
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this? was this mentioned in the slack convo you had with @bf4? might be a good idea to state why you need respond_to.

Copy link
Member

@bf4 bf4 Aug 30, 2016

Choose a reason for hiding this comment

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

This is more like the following story:

render jsonapi: foo

Client: Hello. I am sending you JSONAPI data. Tell me what you think. I only understand answers in terms of JSON API data
Server: Here's some JSON API data

respond_to do |format| format.jsonapi { render jsonapi: foo } end

Client: Hello. I am sending you JSONAPI data. Tell me what you think. I only understand answers in terms of JSON API data
Server: You want JSON API data? Lemme see if I can do that. I can. Here's some JSON API data

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this story.

Copy link
Member

Choose a reason for hiding this comment

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

Which means

Rails also requires your controller to tell it that you accept and generate JSONAPI data

Isn't quite true. Rails even has an ignore_accept_header

@bf4
Copy link
Member

bf4 commented Aug 31, 2016

You may want to rebase this off of master.

@@ -102,18 +118,16 @@ export default DS.JSONAPISerializer.extend({

```


## Including Nested Resources
Copy link
Member

Choose a reason for hiding this comment

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

Would be great to mention the whole 'embedded resources' controversy here and how it's not JSON API so we don't do it, but ....

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, maybe mention the difference between including, and embedding, and that there are ways to embed, such as: https://github.com/NullVoxPopuli/aeonvera/blob/master/config/initializers/active_model_serializers.rb#L18

@NullVoxPopuli
Copy link
Contributor

@Ikariusrb do you think you can finish this up?

Updates to address comments; explain why Rails should know what format we are consuming/generating, reword introduction to include: examples, and fix render statement to specify jsonapi instead of json.
@NullVoxPopuli NullVoxPopuli merged commit 58ebf96 into rails-api:master Sep 7, 2016
richmolj pushed a commit to richmolj/active_model_serializers that referenced this pull request Sep 16, 2016
* Update ember-and-json-api.md

Removed ember-data adapter change to support include directives, as it's now built-in.  Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data

* Fix up format for parameter restrictions

* Update ember-and-json-api.md

Updates to address comments; explain why Rails should know what format we are consuming/generating, reword introduction to include: examples, and fix render statement to specify jsonapi instead of json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants