For the last 2 hours i tried to define a self referencing relationship in ember data - without any luck.
Idea is simple: Be able to have one item refer to multiple other items of the same class.
I tried every possible combination i could come up with, always just resulting it not helpful error messages like so:
Uncaught #<error> VM21795:956
ProfileManager.ended VM21795:956
Ember.subscribe.after VM21795:2007
finalizer ember.js:1802
Ember.tryCatchFinally ember.js:1554
Ember.Instrumentation.instrument ember.js:1810
Ember.CoreView.Ember.Object.extend.renderToBuffer ember.js:22472
Ember.merge.renderToBufferIfNeeded ember.js:24960
Ember.View.Ember.CoreView.extend.renderToBufferIfNeeded ember.js:24169
Ember.merge.ensureChildrenAreInDOM ember.js:25622
Ember.ContainerView.Ember.View.extend._ensureChildrenAreInDOMember.js:25587
DeferredActionQueues.flush ember.js:6127
Backburner.end ember.js:6215
Backburner.run ember.js:6254
executeTimers ember.js:6552
(anonymous function) ember.js:6542
This is my code (at least one version of it):
var Location = DS.Model.extend({
name: DS.attr(),
to: DS.hasMany('location', {inverse: 'to'})
});
Location.reopenClass({
FIXTURES: [
{
id: "start",
name: "Your Room",
to: ["left"]
}, {
id: "left",
name: "Left",
to: ["start"]
}
]
});
I have tried with/without the inverse definition. With a different inverse than the main relationship (with and without ids for the back reference). I tried different names for it. And on and on for the past 2 hours…
Should ember-data be able to handle this case at all? And if so how? I’d really like to stick to ember-data as i have used it in the past quite happily.
I’m using: Ember 1.5.1 with Ember Data 1.0.0-beta.8.2a68c63a (App Kit)