Hello,
I have two models:
campaign:
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
address: DS.belongsTo('address')
});
address:
import DS from 'ember-data';
export default DS.Model.extend({
campaign: DS.belongsTo('campaign'),
name: DS.attr('string'),
lat: DS.attr('number'),
lon: DS.attr('number')
});
A route campaign_new:
export default Ember.Route.extend({
model() {
let campaign = this.store.createRecord('campaign');
this.store.createRecord('address', {
campaign: campaign
});
return campaign;
},
exit() {
let campaign = this.currentModel;
let address = campaign.get('address');
if (address.get('id') == null)
address.destroyRecord();
if (campaign.get('id') == null)
campaign.destroyRecord();
}
});
But on exit, this error occured:
Error while processing route: app.campaigns address.destroyRecord is not a function TypeError: address.destroyRecord is not a function
I have a similar error on address.save().
(My models and routes are simplified for more readibility).
Anyone has an idea ?