Ruby on rails rails:rails上的主干gem文件命名约定对错误负责?
下面是Ryan Bates RailsCast Backbone.js教程。这张图片是他的教程的截图 注意,在views/entries/目录中,有一个名为“entries\u index.js.coffee”的文件 当我生成脚手架时,该文件被简单地称为Ruby on rails rails:rails上的主干gem文件命名约定对错误负责?,ruby-on-rails,backbone.js,Ruby On Rails,Backbone.js,下面是Ryan Bates RailsCast Backbone.js教程。这张图片是他的教程的截图 注意,在views/entries/目录中,有一个名为“entries\u index.js.coffee”的文件 当我生成脚手架时,该文件被简单地称为index.js.coffee 这可能很重要,因为Ryan使用EntrieIndex在路由器中实例化视图 index: -> new Raffler.Views.EntriesIndex() $('#container')
index.js.coffee
这可能很重要,因为Ryan使用EntrieIndex
在路由器中实例化视图
index: ->
new Raffler.Views.EntriesIndex()
$('#container').html(view.render().el)
然后在entries_index.js.coffee文件中呈现模板
render: ->
$(@el).html(@template())
this
为了演示,应该把这个放在容器div中
<h1>Raffler</h1>
由于文件条目_index.js.coffee
vindex.js.coffee
的名称不同,我想知道Ryan以这种方式实例化视图是否有意义(即用驼峰大小写代替下划线)
如果我改变它并尝试
new Raffler.Views.Index()
我得到了错误
Raffler.Views.Index is not a constructor
[Break On This Error]
new Raffler.Views.Index();
你知道我怎样才能回到正轨吗 我重新键入了代码,它现在可以正常工作了。这一定与coffee脚本中的缩进有关
new Raffler.Views.Index()
Raffler.Views.Index is not a constructor
[Break On This Error]
new Raffler.Views.Index();