I have a polymorphic record type in my ember application. Posts has a polymorphic association called response, which can be a few kinds of response.
// post.js
import DS from 'ember-data';
export default DS.Model.extend({
...
responses: DS.hasMany('response', { polymorphic: true })
});
The response model is the basis for all the other types.
// response.js
import DS from 'ember-data';
export default DS.Model.extend({
post: DS.belongsTo('post'),
message: DS.attr('string')
});
For example, a comment inherits from response.
// comment.js
import Response from '../models/response';
export default Response.extend();
This works perfectly for loading models using ember-data. It correctly connects to /responses
on the Rails server for all types of responses.
However when I try to delete a record using record.destroyRecord()
it sends the delete to /comments
on the server, instead of /responses
. Because this is a polymorphic record there is no comments
route on the server.
Is there some other part of ember-data where I can indicate the record deletion should be polymorphic?
Aucun commentaire:
Enregistrer un commentaire