I've got an odd issue with ember js, when i push an object to a model. Here is my code:
// Environment.js
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: true,
Array: true,
}
Route.js
model () {
return Ember.RSVP.hash({
newCollection: this.get('store').createRecord('collection'),
book1: this.get('store').createRecord('book'),
book2: this.get('store').createRecord('book')
})
}
Controller
actions:{
addCollection(model) {
model.newCollection.pushObject(model.book1);
model.newCollection.pushObject(model.book2);
},
}
Now I'm not sure what the issue, but I'm trying to push the book model into the collection, however, I get an issue with this as the console log suggests that pushObject is not a function. I've updated my Environment.js as other questions have suggested, however this still is an issue.
Collection Model
// collection Model
export default DS.Model.extend({
name: DS.attr('string'),
city: DS.attr('string'),
books: DS.hasMany('book', { async: true })
});
The book model
//book Model
export default DS.Model.extend({
title: DS.attr('string'),
description: DS.attr('string'),
collection: DS.belongsTo('collection', {async: true})
});