I have an Evaluation model in my EmberData, which has a belongsTo relationship with Thread model. I'd like to create a new thread and assign it to the Evalutation and then save it to backend. My code looks like this:
var thread = self.get("store").createRecord("thread", {
title: self.get("thread_name"),
private: true
});
thread.save().then(function() {
var post = self.get("store").createRecord("post", {
author: self.get("session.profile.id"),
body: self.get("thread_content"),
thread: thread,
private: true
});
return post.save();
}).then(function() {
// assign the realtionship - HERE is the problem
this.set("model.comment, thread); // This call fails
return this.get("model").save();
}
I am getting this unclear stacktrace...
post_thread/<@http://localhost:4200/assets/ksi.js:370:21
tryCatch@http://localhost:4200/assets/vendor.js:64238:14
invokeCallback@http://localhost:4200/assets/vendor.js:64253:15
publish@http://localhost:4200/assets/vendor.js:64221:9
@http://localhost:4200/assets/vendor.js:41059:7
Queue.prototype.invoke@http://localhost:4200/assets/vendor.js:10314:9
Queue.prototype.flush@http://localhost:4200/assets/vendor.js:10378:11
DeferredActionQueues.prototype.flush@http://localhost:4200/assets/vendor.js:10178:11
Backburner.prototype.end@http://localhost:4200/assets/vendor.js:9571:9
Backburner.prototype.run@http://localhost:4200/assets/vendor.js:9639:13
run@http://localhost:4200/assets/vendor.js:28889:12
ember$data$lib$adapters$rest$adapter$$RestAdapter<.ajax/</hash.success@http://localhost:4200/assets/vendor.js:72687:15
jQuery.Callbacks/fire@http://localhost:4200/assets/vendor.js:3301:10
jQuery.Callbacks/self.fireWith@http://localhost:4200/assets/vendor.js:3413:7
done@http://localhost:4200/assets/vendor.js:8466:5
.send/callback/<@http://localhost:4200/assets/vendor.js:8807:1
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire