问题
According to the URL conventions, it is possible to customize the pluralization, endpoint path and host for the REST adapter. I have a model called VoiceMenu
, and the adapter is performing requests to api/voice-menus/
, as per the URL-conventions. But they should instead be sent to api/voicemenus/
. I do not want to change the name of my model.
How can I configure the REST adapter, for this particular model?
回答1:
Assuming you have api
set already on your adapter, you can set the url on a per model basis like this:
App.VoiceMenu = DS.Model.extend({
url: '/voicemenus'
...
});
Hope it helps.
回答2:
I got it working with:
App.Adapter.configure('plurals', {
voice_menu : 'voicemenus',
});
I really do not like this, because this has nothing to do with plurals, but I know no other way to configure this.
来源:https://stackoverflow.com/questions/17956041/customize-path-on-a-per-model-basis-for-the-rest-adapter