in ember 2.7 with ember data i have a route with models created with 'RSVP.hash' like the example here :
model: function(params){
return Ember.RSVP.hash({
customer: this.store.findRecord('customer', params.customer_id),
address: this.store.createRecord('address')
});
I want to save the 'address' part of the model ? model.save() gives as result: 'Uncaught TypeError: model is not a function' what can i do to save only the address part of the model ?
this is is the action that saves the model :
createAddress: function(model){
console.log(model.address.constructor);
model.address.save();
}
models (address):
import DS from 'ember-data';
export default DS.Model.extend({
id_address: DS.attr('number'),
id_customer_fb: DS.attr(),
id_customer: DS.attr('number'),
id_supplier: DS.attr('number'),
id_state: DS.attr('number'),
id_country: DS.attr('number'),
postcode: DS.attr('string'),
active: DS.attr('boolean'),
address1: DS.attr('string'),
address2: DS.attr('string'),
city: DS.attr('string'),
alias: DS.attr('string'),
company: DS.attr('string'),
vat_number: DS.attr('string'),
firstname: DS.attr('string'),
lastname: DS.attr('string'),
other: DS.attr('string'),
phone: DS.attr('string'),
phone_mobile: DS.attr('string'),
deleted: DS.attr('boolean'),
// date_add: DS.attr('date'),
// date_upd: DS.attr('date'),
customer: DS.belongsTo('customer')
});
models customer :
import DS from 'ember-data';
export default DS.Model.extend({
id_count: DS.attr('number'),
id_customer: DS.attr('number'),
id_default_group: DS.attr('number'),
id_lang: DS.attr('number'),
id_gender: DS.attr('number'),
active: DS.attr('boolean'),
email: DS.attr(),
firstname: DS.attr(),
lastname: DS.attr(),
company: DS.attr(),
birthday: DS.attr('date'),
date_add: DS.attr('date'),
date_upd: DS.attr('date'),
max_payment_days: DS.attr('number'),
newsletter: DS.attr('boolean'),
note: DS.attr(),
website: DS.attr(),
addresses: DS.hasMany('address')
});