领先角色脱离API通话 [英] Leading character stripped off of API call
问题描述
我开始设置商店:
App.Store = DS.Store.extend({
revision:11,
adapter:DS.RESTAdapter.reopen({
namespace:'api / admin'
})
});
然后我设置一个模型(在REST服务上被称为dbx_tables p>
App.dbxTable = DS.Model.extend({
name:string,
db_column:字符串
});
然后有路由:
App.DbxRoute = Ember.Route.extend({
model:function(){
return App.dbxTable.find );
}
});
我已经打开了日志记录的转换:
App = Ember.Application.create({
LOG_TRANSITIONS:true
});
所以当我启动应用程序时,它首先切换到关于页面,然后点击dbx视图(我不知道为什么它说 dbx.index
,而不仅仅是 dbx
):
DEBUG:------------------------- ------ ember-1.0.0-rc.1.js:339
DEBUG:Ember.VERSION:1.0.0-rc.1 embe r-1.0.0-rc.1.js:339
DEBUG:Handlebars.VERSION:1.0.0-rc.3 ember-1.0.0-rc.1.js:339
DEBUG:jQuery .VERSION:1.9.1 ember-1.0.0-rc.1.js:339
DEBUG:------------------------- ------ ember-1.0.0-rc.1.js:339
转换为'about'ember-1.0.0-rc.1.js:339
转换为'dbx。索引'ember-1.0.0-rc.1.js:339
GET http:// lifegadget-local / api / admin / bx_tables 404(未找到)jquery-1.9.1.js:8526 $ b $在API调用中,请注意引用 bx_tables
领先的d如何被删除?我也不知道为什么它的复数形式,尽管这可以很容易地符合惯例,所以不是真的很担心。
好的,看起来像我做了一个约会错误,模型的缺乏大小写是导致问题的原因。因此,通过将 App.dbxTable
切换到 App.DbxTable
,我已经解决了问题。
I am attempting to setup a REST model and have a problem that is completely befuddling me: the API call that is generated seems to remove the first letter of the model and therefore is unable to retrieve the data (gets 404 error).
I start by setting up the store:
App.Store = DS.Store.extend({
revision: 11,
adapter: DS.RESTAdapter.reopen({
namespace: 'api/admin'
})
});
Then I setup a model (which is referred to as "dbx_tables" on the REST service:
App.dbxTable = DS.Model.extend({
name: "string",
db_column: "string"
});
Then there is the route:
App.DbxRoute = Ember.Route.extend({
model: function() {
return App.dbxTable.find();
}
});
I've turned on the logging of transitions:
App = Ember.Application.create({
LOG_TRANSITIONS: true
});
So when I start the application it transitions first to the "about" page and then I click over to the "dbx" view (I'm not sure why it says dbx.index
rather than just dbx
):
DEBUG: ------------------------------- ember-1.0.0-rc.1.js:339
DEBUG: Ember.VERSION : 1.0.0-rc.1 ember-1.0.0-rc.1.js:339
DEBUG: Handlebars.VERSION : 1.0.0-rc.3 ember-1.0.0-rc.1.js:339
DEBUG: jQuery.VERSION : 1.9.1 ember-1.0.0-rc.1.js:339
DEBUG: ------------------------------- ember-1.0.0-rc.1.js:339
Transitioned into 'about' ember-1.0.0-rc.1.js:339
Transitioned into 'dbx.index' ember-1.0.0-rc.1.js:339
GET http://lifegadget-local/api/admin/bx_tables 404 (Not Found) jquery-1.9.1.js:8526
notice the reference to bx_tables
in the API call. How did the leading "d" get removed? I also wasn't sure why it pluralized the call although that could easily fit into convention so not really worried about that.
Ok, looks like I made a "convention error" and the model's lack of capitalisation was what was causing the problems. So by switching the App.dbxTable
to App.DbxTable
I have now sorted out the problem.
这篇关于领先角色脱离API通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!