Customize path on a per-model basis, for the REST adapter

萝らか妹 提交于 2019-12-11 19:59:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!