Sideloading is working in our app for hasMany relationships, but I can't get it to work for belongsTo relationships. I'm trying to use the documented DS.RESTAdapter.configure()
method, but that doesn't seem to have any effect. The error I am getting is Uncaught Error: assertion failed: Your server returned a hash with the key occasions but you have no mapping for it
.
Note that we don't need to specify the hasMany
sideload mappings, as that request just works. App.Occasion.find();
works fine. App.Reminder.find();
throws the error.
Models
App.Reminder = DS.Model.extend(
occasion: DS.belongsTo('App.Occasion')
...
)
App.Occasion = DS.Model.extend(Ember.Validations,
reminders: DS.hasMany('App.Reminder')
...
)
Store.js.coffee
DS.RESTAdapter.configure('App.Occasion',
sideLoadAs: 'occasions'
)
App.Store = DS.Store.extend(
revision: 11
adapter: DS.RESTAdapter.create()
)
JSON (for occasions)
{
reminders: [{},...],
occasions: [{reminders: [1,2,...]},...]
}
JSON (for reminders)
{
reminders: [{occasion_id: 1},...],
occasions: [{},...]
}