Fix redirect to posts list when saving a new post as an author

no issue
- replace deprecated `normalizeHash` with `normalize` in post serializer
- ensure we check for both `post` and `posts` properties as it will vary depending on the expected response type
This commit is contained in:
Kevin Ansfield 2016-04-13 15:19:44 +01:00 committed by Austin Burdine
parent 0f39b4c53c
commit 490f2bae16

View File

@ -9,14 +9,15 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
tags: {embedded: 'always'} tags: {embedded: 'always'}
}, },
normalizeHash: { normalize(model, hash, prop) {
// this is to enable us to still access the raw authorId // this is to enable us to still access the raw authorId
// without requiring an extra get request (since it is an // without requiring an extra get request (since it is an
// async relationship). // async relationship).
posts(hash) { if ((prop === 'post' || prop === 'posts') && hash.author !== undefined) {
hash.author_id = hash.author; hash.author_id = hash.author;
return hash;
} }
return this._super(...arguments);
}, },
normalizeSingleResponse(store, primaryModelClass, payload) { normalizeSingleResponse(store, primaryModelClass, payload) {