Okay. I've had a real good look through SO and other sources returned by Google, but am yet to find an answer to my problem.
I have two models:
App.Kid = Ember.Model.extend
title: DS.attr "string"
parent: DS.belongsTo "App.Parent"
App.Parent = Ember.Model.extend
title: DS.attr "string"
kids: DS.hasMany "App.Kid"
Most questions on here discuss retrieving ember data relationships from sideloaded JSON data, which I'm capable of doing. What I need to know is how do I save the parent_id when creating a new kid?
At the moment I'm saving a new kid in the App.KidController like so:
App.ParentController = Ember.ObjectController.extend
needs: [ "widgets" ]
App.KidCreateController = Ember.ObjectController.extend
needs: [ "dashboard" ]
saveChild: ->
@content.get( "store" ).commit()
And when saving there is no parent_id to be seen, however I do get a new parent object (assigned to a parent key) with the id of 0.
Can anybody explain what I'm doing wrong here?
Update 1
So using my actual situation I'll explain what I'm doing.
A user has several dashboards which have multiple widgets attached to it. My model structure looks like this:
App.Dashboard = DS.Model.extend
title: DS.attr "string"
widgets: DS.hasMany "App.Widget"
App.Widget = DS.Model.extend
title: DS.attr "string"
type: DS.attr "string"
...
dashboard: DS.belongsTo "App.Dashboard"