1

In my application I'm having two way 1:1 relationships between models. When trying to set an association between them i get ...

Uncaught RangeError: Maximum call stack size exceeded

... and the trace repeats

OrderedSet.forEach
Map.forEach
DS.Model.Ember.Object.extend.toJSON
DS.Model.Ember.Object.extend.addBelongsToToJSON
DS.Model.Ember.Object.extend.toJSON
Map.forEach
OrderedSet.forEach

Relevant parts of the code:

App.Employee = DS.Model.extend( {
    // ... 
    recruitment:DS.belongsTo( 'App.Recruitment', { embedded: true } )
} );

App.Recruitment = DS.Model.extend( {
    // ...
    employee:DS.belongsTo( 'App.Employee', { embedded: true } ),
} );

// ...

recruitment.set('employee', employee);
employee.set('recruitment', recruitment);
App.store.commit(); // <= boom

Is this something that Ember Data should support or am I approaching this all wrong?

2 Answers 2

2

Ember-Data does not support one-to-one associations at the moment.

2
  • Thanks. I supppose this is functionality that will be available in the stable release?
    – rickard2
    Oct 12, 2012 at 18:39
  • I found this github issue where the issue is being discussed. It seems like I just have to implement some workaround myself for the time being.
    – rickard2
    Nov 8, 2012 at 20:30
0

This has been fixed, and is now a straight-forward process of making the models belong to each other:

App.User = DS.Model.extend({
  profile: DS.belongsTo('profile')
});

App.Profile = DS.Model.extend({
  user: DS.belongsTo('user')
});

The above is an example from http://emberjs.com/guides/models/defining-models/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.