You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code example used in the Relationships > Saving section:
actions:{addComment(comment,author){//Create the commentconstcomment=this.store.createRecord('comment',{comment: comment,author: author});//Get our postconstpost=this.controller.get('model');//Add our comment to our existing postpost.get('comments').pushObject(comment);//Save the child then the parentcomment.save().then(()=>post.save());}}
"comment" is used both as a function parameter and a constant name. I found this example initially confusing because I was reading quickly the first time through, and I'm a relatively new Ember user.
I was also experiencing the problem in #160 and though I might be missing the belongsTo relationship. I thought perhaps the example might be wrong. An explicit note that the belongsTo relationship isn't required would have been reassuring. :)
Suggestions:
Change the function parameter to: addComment(commentText, author) or something similar
Explicitly note in comments that the belongsTo definition is not required
For example:
actions:{addComment(commentText,author){//Create the commentconstcomment=this.store.createRecord('comment',{// Do not need to specify the belongsTo attribute // of post: post, it's added automaticallycomment: commentText,author: author});//Get our postconstpost=this.controller.get('model');//Add our comment to our existing postpost.get('comments').pushObject(comment);//Save the child then the parentcomment.save().then(()=>post.save());}}
The text was updated successfully, but these errors were encountered:
In the code example used in the Relationships > Saving section:
"comment" is used both as a function parameter and a constant name. I found this example initially confusing because I was reading quickly the first time through, and I'm a relatively new Ember user.
I was also experiencing the problem in #160 and though I might be missing the belongsTo relationship. I thought perhaps the example might be wrong. An explicit note that the belongsTo relationship isn't required would have been reassuring. :)
Suggestions:
For example:
The text was updated successfully, but these errors were encountered: