Closed tobiaswerner closed 11 years ago
Can you post your model code for Gear and User?
Sure. Here it is...
var attr = Ep.attr,
belongsTo = Ep.belongsTo,
hasMany = Ep.hasMany;
App.Gear = Ep.Model.extend({
user: belongsTo('App.User'),
manufacturer: belongsTo('App.Manufacturer'),
description: attr('string')
});
var attr = Ep.attr,
belongsTo = Ep.belongsTo,
hasMany = Ep.hasMany;
App.User = Ep.Model.extend({
name: attr('string'),
gears: hasMany('App.Gear')
});
Nothing special so far, I think... Thanks for your help in advance :)
Without testing it out myself, I think is this is probably related to #4. EPF doesn't yet support defining relationships via strings, so try declaring your models like this:
App.Gear = Ep.Model.extend({
description: attr('string')
});
App.Manufacturer = Ep.Model.extend({
gears: hasMany(App.Gear)
});
App.User = Ep.Model.extend({
name: attr(string),
gears: hasMany(App.Gear)
});
App.Gear.reopen({
user: belongsTo(App.User),
manufacturer: belongsTo(App.Manufacturer)
});
You need to use reopen
whenever there is a circular dependency. Take a look at #4 though as this won't be necessary in the future.
Perfect, many thanks for your explanation. Will try it tomorrow...
I think @jasonkriss is correct. I will try and get #4 fixed soon. I'm going to close this for now, feel free to reopen if that isn't the fix.
Your hints solved my problem. Many thanks :+1:
I have problems deserializing embedded relationships.
Up to now I could figure out that deserializeEmbeddedBelongsTo() which calls deserializeModel receives a string as type. deserializeModel() in turn tries to .create() the model but still fail (because it is typeof string).
I configured the RestAdapter to always embed the one model in the other one..
Did I miss some configuration?