在序列化JsonApi模型时,是否有一种快速简便的方法来使用z[:]
?默认情况下,对于网址和字段名称都使用camel case
。
答案 0 :(得分:2)
请查看EmberJS guides以获取与user-profile
相关的适配器匹配user_profile
的示例:
export default DS.JSONAPIAdapter.extend({
pathForType: function(type) {
return Ember.String.underscore(type);
}
});
person
的请求现在将定位/person/1
。user-profile
的请求现在将定位/user_profile/1
如果您需要序列化属性,而不仅仅是模型名称,您可以在同一位置找到该主题的相关部分,直接链接here。
由于上面的示例使用了Ember.String.underscore()
,因此我附加了一个非常有用的字符串助手的链接,默认情况下,Ember提供了Ember.String API: