2014-07-03 31 views
3

我遇到了一個非常奇怪的錯誤:昨天我編寫了一個ember.js應用程序的開始,測試它(一切正常),並將其推送到我的github repo。今天我剛跑grunt serve(就像我昨天所做的那樣),但現在我在瀏覽器控制檯中開始輸入錯誤TypeError: newHandlerInfo is undefinedTypeError:newHandlerInfo未在emberjs中定義

我不知道該顯示什麼,所以你可以檢查回購代碼。 https://github.com/OpenCubes/OpenCubes

一些調試後,我發現,而不是拋出一個錯誤,它在燼代碼是null返回oldHandlerInfo

// Ideally we should throw this error to provide maximal 
// information to the user that not enough context objects 
// were provided, but this proves too cumbersome in Ember 
// in cases where inner template helpers are evaluated 
// before parent helpers un-render, in which cases this 
// error somewhat prematurely fires. 
//throw new Error("Not enough context objects were provided to complete a transition to " + targetRouteName + ". Specifically, the " + name + " route needs an object that can be serialized into its dynamic URL segments [" + names.join(', ') + "]"); 
return oldHandlerInfo; // = UNDEFINED 

而且應該已經拋出的錯誤是:

Not enough context objects were provided to complete a transition to view. Specifically, the mod route needs an object that can be serialized into its dynamic URL segments [mod_model.j_id]

回答

1

你的slu((:foo_id)應該匹配模型上的屬性名稱(或者你必須做所有的序列化,最簡單的匹配)。它應該是唯一的,並且可以在不知道其他事物(即主鍵)的情況下找到該資源。真的,最有意義的是使用你的記錄的ID,:id(尤其是因爲你使用Ember數據)。現在

OpencubesDashboard.Router.map(-> 
    @resource 'mods', path: '/' 
    @resource 'mod', -> 
    @resource 'mod', path: '/:id', -> 
     @resource 'view', path: '/view' 
     @resource 'edit', path: '/edit' 

    @route('create') 


) 

你的Mod的路線,應該使用slug名

OpencubesDashboard.ModRoute = Ember.Route.extend(
    model: (params) -> 
    @get('store').find('mod', params.id) 
) 

另外您查看和編輯資源,最有可能的編輯/查看的MOD資源定義(也許不是,我的資源我只是猜測)。

OpencubesDashboard.ModViewRoute = Ember.Route.extend(
    model: (params) -> 
    @modelFor('mod') 
    setupController: (controller, model) -> 
    controller.set 'model', model 
    buffer = model.get('attributes').map (attr)-> 
     { key: attr.get('key'), value: attr.get('value') } 
    controller.set 'buffer', buffer 

) 
+0

非常感謝! – Vinz243