Ghost/ghost/admin/serializers/post.js
David Arvelo beb409dd5f Fix serializing/deserializing Tags on save from the Editor
closes #2947
- make a PostSerializer to embed the tags objects in the posts POST/PUT request
- on editor save, clear out tags from the post and data store that have `id: null`
2014-06-13 02:44:45 -04:00

18 lines
509 B
JavaScript

import ApplicationSerializer from 'ghost/serializers/application';
var PostSerializer = ApplicationSerializer.extend({
serializeHasMany: function (record, json, relationship) {
var key = relationship.key;
if (key === 'tags') {
json[key] = Ember.get(record, key).map(function (tag) {
return tag.serialize({ includeId: true });
});
} else {
this._super.apply(this, arguments);
}
}
});
export default PostSerializer;