Ghost/ghost/admin/app/serializers/application.js
Kevin Ansfield 186a8ae70c Remove UUID attrs from all models except Post (#404)
refs https://github.com/TryGhost/Ghost/issues/7494
- remove `uuid` attrs from all models except Post
- remove uuids from mirage factories and fixtures
- add a workaround for tags where the selectize-based tags input on the PSM relies on a unique identifier for each tag which doesn't get sent back to the server when saving (fixes the broken tags input caused by uuid removal in https://github.com/TryGhost/Ghost/pull/7495)
2016-11-17 11:38:47 -06:00

24 lines
630 B
JavaScript

import Ember from 'ember';
import {decamelize} from 'ember-string';
import RESTSerializer from 'ember-data/serializers/rest';
const {String: {pluralize}} = Ember;
export default RESTSerializer.extend({
serializeIntoHash(hash, type, record, options) {
// Our API expects an id on the posted object
options = options || {};
options.includeId = true;
// We have a plural root in the API
let root = pluralize(type.modelName);
let data = this.serialize(record, options);
hash[root] = [data];
},
keyForAttribute(attr) {
return decamelize(attr);
}
});