Is there a way in Ember to configure a custom REST url for a specific Model?
Like with this model:
App.Post = DS.Model.extend({
title: DS.attr('string'),
comments: DS.hasMany('App.Comment')
});
App.Comment = DS.Model.extend({
content: DS.attr('string'),
post: DS.belongsTo('App.Post')
});
And this Store:
app.Store = DS.Store.extend({
revision : 11,
adapter : DS.RESTAdapter.extend({
namespace : 'rest'
})
});
I want that the comments are retrieved via /rest/post/{id}/comments
instead of /rest/comments
which is the default behaviour.
Is it possible to configure a rest-url for one specific Model?
You can register an additional adapter and 'scope' it to your model.
App.Store.registerAdapter('App.Post', DS.RESTAdapter.extend({
url: "/rest/post/"
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With