In my quiz manager, I am working on allowing users to add questions and edit the answers for those questions. My goal is to have a single save button that saves both the questions and their corresponding answers. However, when trying to access and call the save() method from the question save(), I encounter an error stating "There is no save method". Please let me know if you require more information.
Question Controller
App.QuestionController = Ember.ObjectController.extend({
softSave: function() {
var self = this;
this.get('model').save().then(function() {
self.get('answers').save();
console.log('%c Question was saved','color:green;');
}, function() {
console.log('%c Question not saved', 'color:red;');
});
}
}
});
Question Model
App.Question = DS.Model.extend({
'quiz': DS.belongsTo('quiz'),
'text': attr('string'),
'ord': attr('number'),
'answers': DS.hasMany('answer' , { async: true } )
});
Answer Model
App.Answer = DS.Model.extend({
'question': DS.belongsTo('question'),
'content': attr('string'),
'correct_answer': attr('boolean')
});