Skip to content

belongsTo/hasMany createRecord vs set behavior difference #529

leepfrog opened this Issue Dec 16, 2012 · 8 comments

7 participants


It appears that when you use createRecord() and set belongsTo attributes, the hasMany side of the association does not get the newly created record.

If you use set(), everything works as expected.

Ember.js member
wagenet commented Jan 10, 2013

@leepfrog Is this still an issue in master?


let me test and get back to you

sly7-7 commented Jan 18, 2013

@leepfrog 👍, you're not alone ;), you know sometimes with ember-data, things are working as exapected (I'm pretty sure I've seen createRecord(parent_id: 1) working), sometimes not. Here is an updated version of your fiddle, demonstrating two ways of populating the many arrays:


👍 still an issue on latest...


A possible fix is given in #544

ashugit commented Feb 20, 2013

I am having a problem with createRecord.
I have this relation
App.Contact = DS.Model.extend({
test: DS.belongsTo('App.Test')

App.Test = DS.Model.extend({
text: DS.attr('string'),
contact: DS.belongsTo('App.Contact')

Test is embedded always in Contact.

I am trying to create a new model object by calling transaction.createRecord(App.Contact), it fails to create Test object. If I make the relation Contact -hasOne-> Test to Contact -hasMany-> Test I am able to call createRecord.

I am not sure how to call createRecord for a new model object for the parent such that all children in one-to-one relationship get initialized.

Please help.

Ember.js member
igorT commented Apr 15, 2013

This is a bug related to the broader problem of syncing relationships. A whole class of these problems should be fixed by a refactor that I will start working on in couple weeks. Closing as a duplicate of #695.

@igorT igorT closed this Apr 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.