Skip to content

fix: update docs to reflect correct record handling #18

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This is an Ember app, so the usual steps follow:
```
1. Run the app.
```bash
ember serve
npm run start
```
1. Visit your app at [http://localhost:4200](http://localhost:4200).

Expand Down
9 changes: 5 additions & 4 deletions snippets/updating-data/create-record/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ const updatesHandler = {

const { data, store } = context.request;
const newRequestParams = Object.assign({}, context.request, {
body: serializeResources(
store.cache,
recordIdentifierFor(data.record)
)
body: JSON.stringify(
serializeResources(
store.cache,
data.record
))
});
return next(newRequestParams);
}
Expand Down
7 changes: 3 additions & 4 deletions snippets/updating-data/save-record/handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Create handler for serialization of any record
import { recordIdentifierFor } from '@ember-data/store';
import { serializeResources } from '@ember-data/json-api/request';

const updatesHandler = {
Expand All @@ -18,10 +17,10 @@ const updatesHandler = {

const { data, store } = context.request;
const newRequestParams = Object.assign({}, context.request, {
body: serializeResources(
body: JSON.stringify(serializeResources(
store.cache,
recordIdentifierFor(data.record)
)
data.record
))
});
return next(newRequestParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module('Integration | Component | guide-section/subsection', function (hooks) {
assert
.dom('[data-test-field="Subsection Description"]')
.includesText(
'To create a new record using Ember Data you should use createRecord request and attach "body" to it. In case of JSON:API backend - you can user serializeResources request utility.'
'To create a new record using Ember Data you should use createRecord request and attach "body" to it. In case of JSON:API backend - you can use serializeResources request utility.'
);

const emberClassic = this.element.querySelector(
Expand Down
2 changes: 1 addition & 1 deletion translations/updating-data/create-record/en-us.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
title: createRecord
description: To create a new record using Ember Data you should use <code>createRecord</code> request and attach <code>"body"</code> to it. In case of JSON:API backend - you can user <code>serializeResources</code> request utility.
description: To create a new record using Ember Data you should use <code>createRecord</code> request and attach <code>"body"</code> to it. In case of JSON:API backend - you can use <code>serializeResources</code> request utility.