0
我最近開始實施餘燼數據庫到我的項目,但現在一切都被打破,谷歌瀏覽器的控制檯爲我提供了以下錯誤:燼數據錯誤而載入路線:類型錯誤{}
- Error while loading route: TypeError {}
- Uncaught TypeError: Cannot read property 'id' of undefined
- Port: Could not establish connection. Receiving end does not exist.
的我試圖打開網址是:/#/音軌/ 85
這是相關代碼:
Shoutzor = Ember.Application.create();
Shoutzor.ApplicationAdapter = DS.RESTAdapter.extend({
namespace: '/api/emberstore',
host: 'http://www.shoutzor.nl'
});
var attr = DS.attr,
hasMany = DS.hasMany,
belongsTo = DS.belongsTo;
Shoutzor.Track = DS.Model.extend({
id: attr('number'),
title: attr('string'),
//length: attr('number'),
//artist: hasMany('artist'),
//album: hasMany('album'),
/* Convert the length in seconds to a string like '01:55' */
convertedLength: function() {
var sec_num = parseInt(this.get('length'), 10); // don't forget the second parm
var hours = Math.floor(sec_num/3600);
var minutes = Math.floor((sec_num - (hours * 3600))/60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10 && hours > 0) {hours = "0"+hours;}
if (minutes < 10 && minutes > 0) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
var time = ((hours != 0) ? hours + ':' : '') + ((minutes != 0) ? minutes +':' : '') + seconds;
return time;
}.property('length')
});
Shoutzor.Album = DS.Model.extend({
id: attr('number'),
artist: belongsTo('artist'),
title: attr('string'),
cover: attr('string')
});
Shoutzor.Artist = DS.Model.extend({
id: attr('number'),
name: attr('string'),
profileimage: attr('string')
});
Shoutzor.Router.map(function() {
//Track Page
this.route("track", { path: "/track/:id" });
});
Shoutzor.TrackRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('pageTitle', "Track");
},
renderTemplate: function() {
this.render('TrackContent', { outlet: 'pageContent', into: 'application' });
},
model: function(params) {
return this.store.find('track', params.id);
}
});
Shoutzor.TrackController = Ember.Controller.extend();
Shoutzor.TrackView = Ember.View.extend();
我的API提供類似這樣的回覆:
{"tracks":{"id":85,"title":"Untitled","file":{"filename":"Lines of Latitude - You want it (Free Download).mp3","filepath":"\/home\/vhosts\/domains\/shoutzor\/music\/Lines of Latitude - You want it (Free Download).mp3","crc":"51ca8346","length":262,"id3":[]},"artist":[],"album":[]}}
我一直在尋找多個SO崗位和谷歌的搜索結果,但這些都不解決我的問題(或者說我找錯了東西),
任何幫助,不勝感激!
的作品:)謝謝!你知道如何讓RESTAdapter以「/」結尾嗎? – xorinzor
如果你需要玩的URL構造,嘗試覆蓋RESTAdapter#buildURL – ahaurw01
我有一個後續問題,希望你們可以幫助我http://stackoverflow.com/questions/19431300/ember-data-assertion-failed-不能叩獲得與 - 查詢上的,不確定的對象 – xorinzor