Answer the question
In order to leave comments, you need to log in
How to make different serializers for the same Ember.js model?
Ember.js 2.7 pods
have the following
/pods
/pods/order/model.js
/pods/order/serializer.js
/pods/order/index/route.js
/pods/order/index/template.hbs
/pods/order/ edit/route.js
/pods/order/edit/template.hbs
/pods/order/new/route.js
/pods/order/new/template.hbs
router.js
this.route('order', { path: '/dashboard/order/' }, function(){
this.route('new');
this.route('edit', { path: '/:order_id/edit' });
});
import DS from 'ember-data';
export default DS.Model.extend({
customer: DS.belongsTo('customer', {async: true}),
});
import RESTSerializer from 'ember-data/serializers/rest';
import DS from 'ember-data';
export default RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
customer: {embedded: 'always'},
}
});
Answer the question
In order to leave comments, you need to log in
I tried to put serialize.js in each folder (index, edit, new), but it doesn't work like that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question