2011-12-19 58 views
0

我一直在跟随cloudedit教程http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/为我的rails应用程序添加主干,但我使用rails 3.1.3而不是3.0。骨干应用程序未定义错误

我不断收到以下错误

 
Uncaught TypeError: Cannot call method 'extend' of undefined 
application.js:7Uncaught TypeError: undefined is not a function 

我相信错误是由下面的代码

 
var App = { 
    Views: {}, 
    Controllers: {}, 
    Collections: {}, 
    init: function() { 
     new App.Controllers.Recipes(); 
     Backbone.history.start(); 
    } 
}; 

这是非常正确的,从本教程造成的。 目前,我有这个代码

assets/javascripts/application.js
文件,其中包括我的目录中部分下面,我叫

 
     $(function(){ 
     App.init(); 
      }); 

在我application.html.erb文件。

该错误实际上是指该行

 
App.Controllers.Recipes = Backbone.Controller.extend(

我试着走动了var应用到不同的文件,但我似乎无法得到它的工作。

我理解错误是否正确?有什么我可能会失踪?

回答

2

您是否正在使用骨干版本> = 0.5.0如果是这样,则不存在Controller对象。它已更名为Router

+0

就是那个!谢谢 – pedalpete 2011-12-19 20:02:27