Hey guys,
I have an issue getting any sideloaded hasMany relationships to work in the ember-data 1.0.0-beta builds. I’ve gone over the docs and I can’t see what I’m doing wrong, but if I call
model.get('relationship.length')
The result is always 0, and there are no relationships. This is my test case.
I have a json response like this:
{
"categories": [{
"id": "b01a0378-49e9-4dd2-aa35-ff2cab8fb3a4",
"name": "my category"
}],
"shop": {
"id": "0eda4921-e2f6-4a8e-b802-e01df49bc958",
"category_ids": [
"b01a0378-49e9-4dd2-aa35-ff2cab8fb3a4"
],
}
}
I’ve set up appropriate inflection:
Ember.Inflector.inflector.rules.irregular['category'] = 'categories'
And I have models like this:
App.Shop = DS.Model.extend
categories: DS.hasMany 'category'
App.Category = DS.Model.extend
name: DS.attr 'string'
My application route is as follows:
App.ApplicationRoute = Ember.Route.extend
model: ->
@get('store').find('shop', '0eda4921-e2f6-4a8e-b802-e01df49bc958')
setupController: (controller, model) ->
@_super(controller, model)
window.model = model
In the js console, model.get(‘categories’) is always an empty array, and model.get(‘categories.type’) correctly shows “App.Category”.
Things get really weird if I call:
store.find('category', 'b01a0378-49e9-4dd2-aa35-ff2cab8fb3a4')
This returns the category, without hitting the server. It uses the stores cache, so the object is clearly getting built on the initial call.
Any idea why the relationship is never getting attached to the parent object?