ember, ember-data 1.0, rails, rabl
I have next json returning from server:
{ "day":{ "id":5, "expenditures":[{ "id":10, "expense_type":{ "name":"Very Sad", "id":2 } }, {...} ] } }
I have next ember models:
Expense.Day = DS.Model.extend expenditures: DS.hasMany('expenditure') Expense.Expenditure = DS.Model.extend day: DS.belongsTo('day') expenseType: DS.belongsTo('expenseType') Expense.ExpenseType = DS.Model.extend name: DS.attr('string') expenditures: DS.hasMany('expenditure')
And I use ActiveModelSerializer for each model with EmbeddedRecordsMixin, for ex:
Expense.DaySerializer = Expense.ApplicationSerializer.extend DS.EmbeddedRecordsMixin, attrs: expenditures: {embedded: 'always'} Expense.ExpenditureSerializer = Expense.ApplicationSerializer.extend DS.EmbeddedRecordsMixin, attrs: expenseType: {embedded: 'always'} day: {embedded: 'always'} Expense.ExpenseTypeSerializer = Expense.ApplicationSerializer.extend DS.EmbeddedRecordsMixin, attrs: expenditures: {embedded: 'always'}
It propertly loads day and expenditures, but not expense_type. I inject into each serializer merhod extract with console.log and super() for debugging and see, that only DaySerializer executed. What's wrong with me? I am very close to insanity with Ember =(
expense_type
when you expect anexpenseType
. Or is this only a mistake on SO ? Anyway, you should use camelcased property as this is what ember-data expect. – Barthelewayasync: false
to your model relationship definition ? (It's just an idea). – Bartheleway