I am having trouble implementing what I understand to be a polymorphic relationship using ember-data rev12.
I have the following models:
App.Project = DS.Model.extend
lists: DS.hasMany('App.List', { polymorphic: true })
App.Proposal = DS.Model.extend
lists: DS.hasMany('App.List', { polymorphic: true })
App.Employee = DS.Model.extend
lists: DS.hasMany('App.List', { polymorphic: true })
App.List = DS.Model.extend
name: DS.attr('string')
#project: DS.belongsTo('App.Project', { polymorphic: true })
And I am trying to create a new list from the project router like so.
App.ProjectRoute = Ember.Route.extend
events:
newList: (project) ->
lists = project.get('lists')
list = App.List.createRecord(name: 'list1')
lists.pushObject(list)
@store.commit()
But the request to the server is setting the polymorphic keys incorrectly.
I was expecting the payload to look like:
{ list: { name: list1, listable_type: project, listable_id: 100 } }
But got:
{ list: { name: list1, project_type: project, project_id: 100 } }
What am I missing? Is there a way to define the polymorphic type or key?.
Here is my temporary hack