2

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: [{},...]
}
dignoe
  • 1,013
  • 11
  • 17
  • As a workaround, I am sideloading `hasMany` relationships and embedding the `belongsTo` relationships. Our app has two main screens that offer different views of the data, so this shouldn't be too much of a performance hit until I find the real solution. – dignoe Feb 22 '13 at 04:38

1 Answers1

6

try sideloadAs instead of sideLoadAs (not capital L)

Teddy Zeenny
  • 3,971
  • 1
  • 17
  • 20