Skip to content

Instantly share code, notes, and snippets.

@mupkoo
Created June 10, 2014 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mupkoo/e2ea9b3a604126d0f00e to your computer and use it in GitHub Desktop.
Save mupkoo/e2ea9b3a604126d0f00e to your computer and use it in GitHub Desktop.
EmberJS belongsTo
App.User = DS.Model.extend({
name: DS.belongsTo('name', { embedded: true }),
email: DS.attr('string')
});
App.Name = DS.Model.extend({
first: DS.attr('string'),
last: DS.attr('string')
});
App.UserEditController = Ember.ObjectController.extend({
actions: {
save: function () {
var name = this.store.createRecord('name', { first: 'Mirko', last: 'Akov' });
this.set('name', name);
this.get('model').save();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment