Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 没有下划线的Ember ActiveModelAdapter URL?_Javascript_Ember.js - Fatal编程技术网

Javascript 没有下划线的Ember ActiveModelAdapter URL?

Javascript 没有下划线的Ember ActiveModelAdapter URL?,javascript,ember.js,Javascript,Ember.js,我有这个json响应来获取请求=>/checklist {"check_lists": [ { "id": 1, "name": "Example-list-1", "description": "" }, { "id": 2, "name": "Example-list-1", "description": "" } } 为了处理此服务器的下划线命名约定,我使用Ac

我有这个json响应来获取请求=>/checklist

{"check_lists": [
    {
        "id": 1,
        "name": "Example-list-1",
        "description": ""
    },
    {
        "id": 2,
        "name": "Example-list-1",
        "description": ""
    }
}
为了处理此服务器的下划线命名约定,我使用ActiveModelAdapter和ActiveModelSerializer

我遇到的问题是请求url。 我的模型名为App.CheckList=DS.model.extend({…),这就是它开始变得复杂的地方。 如果我打电话

return this.store.find('checkList');
在my route中,Ember启动对/checkLists路由的GET请求,而不是/checkLists=>

GET http://localhost:3000/checkLists 404 (Not Found)
Error while processing route: checklists 
令人惊讶的是,这个错误

buildURL: function(type, id) {
    return this._super(type, id);
},
未使用,因此我没有机会修改url


是否有人知道如何将请求更改为/检查列表???

camellized case和下划线case的映射在
ActiveModelAdapter.pathForType
函数中完成。您可以覆盖它并在那里进行更改。例如,要将camellized case更改为下划线case:

App.ApplicationAdapter = DS.ActiveModelAdapter.extend({
  pathForType: function(type) {
    var decamelized = Ember.String.decamelize(type);
    var underscored = Ember.String.underscore(decamelized);

    //Alternatively, you can change urls to dasherized case using this line
    //var dasherized = Ember.String.dasherize(decamelized);

    return Ember.String.pluralize(underscored);
  }
});

奇怪的是,最新的Ember数据中已经有此代码。您可能希望检查正在运行的版本并升级到该版本,而不是我上面建议的更改。

调用
返回此.store.find('check_list')
?意外的是,此.store.find('check_list'))导致与此.store.find('checkList')相同的错误