I am trying to set up a hasMany relationship for my Style model (hasMany('color_style')), and from what I understand of the documentation, it looks for a style attribute on ColorStyle instances, but my api is sending the attribute style_id, not style. How do I tell the ColorStyle model to read the style_id attribute from the api into the style attribute of the local model (and to translate it back when sending requests)?
The JSON from the api:
{
id:1,
color_id:1,
style_id:1,
customer_id:1,
active_flag:null,
created_at:"2015-02-13T22:35:23.857Z",
updated_at:"2015-02-13T22:35:23.857Z"
}
The Ember Model:
App.ColorStyle = DS.Model.extend({
color: DS.belongsTo('color'), // should be tied to color_id from api
style: DS.belongsTo('style'), // should be tied to style_id from api
customer: DS.belongsTo('customer'), // should be tied to customer_id from api
active_flag: DS.attr('boolean'),
created_at: DS.attr('date'),
updated_at: DS.attr('date')
});
Aucun commentaire:
Enregistrer un commentaire