I am using ember data for my application . I defined two models with belongsTo relationship
App.Queue=DS.Model.extend({
time_added:DS.attr("string"),
description:DS.attr("string"),
video:DS.belongsTo("video")
});
App.Video=DS.Model.extend({
video_url:DS.attr("string"),
title:DS.attr('string'),
duration:DS.attr('number'),
queue:DS.belongsTo('queue')
});
For adding a video to queue , I do
var queue=this.store.createRecord("queue",{time_added:"2014-04-26",description:"Good to have at this time"});
this.store.find('video',44).then(function(data){
queue.set('video',data);
queue.save();
});
response after save will be
{queue:{id:1,time_added:"2014-04-26",description:"Good to have at this time",video:44},
video:[{
id:44,
video_url:"beauty.png",
title:"Cool dance",
duration:"30",
queue:1
}]
}
Now it will create new record in the store . But the problem is after save when i check the queue computed property it shows “App.Queue:ember1724:null” [in belongsTo relationship] and when i click on this property it will fetch new record from the server with the same id and remaining values are undefined . Is anything wrong wth my approach ?
I think you understand my problem . Thanks in advance .