I want to use a delete
method for my backbone model but for some reason, backbone does not include that model ID in produced request URL. To remove my model, i need to fire a following request: DELETE /api/v1/places/12/place_users/12
. Here is my code:
# place_user.model.js
var PlaceUserModel = Backbone.Model.extend({
url: function() {
return this.urlRoot;
},
initialize: function(data, options) {
this.urlRoot = '/api/v1/places/' + options.placeId + '/place_users'
},
});
And i'm trying to remove that using:
# PlaceUsersCollection fetches it's results from a remote api
placeUsers = new PlaceUsersCollection({placeId: 12}).fetch();
# it's obviously more complicated in the app but let's say i just want to
# remove first model
placeUsers.models[0].destroy;
And that code produces a DELETE
request to /api/v1/places/12/place_users
(without a model id included). I'm not sure what else can i post in here to make it easier to help me so please ask if you need anything.
Thanks in advance!