2014-06-17 36 views
1

我試圖使我的項目的基本結構解決。在我的「大師」的文件我有這樣一行調用main.js.coffee腳本文件:Rails javascript_include_tag不按預期工作

<%= javascript_include_tag "application", 'main' %> 
在我的主,我有打電話到下一個js文件

#= require_self 
#= require_tree ./controllers/main/ 


./controllers/main/ contains just 1 single file mainIndexCtrl.js.coffee 

所以這裏是結構:

enter image description here

因此,對URL的呼叫:端口/主/索引application.html.erb被調用來main.js.coffee其中除調用mainIndexCtrl.js.coffee,或更喜歡哪一個呼叫那我想這樣做,因爲不事關我做什麼我不能擺脫如下因素的錯誤:

enter image description here

我是很新的Rails的,所以basicly我真的不知道該怎麼辦,因爲這個錯誤犯規準確對我說任何話。

Main.js.coffee:

# Place all the behaviors and hooks related to the matching controller here. 
# All this logic will automatically be available in application.js. 
# You can use CoffeeScript in this file: http://coffeescript.org/ 

#= require_self 
#= require_tree ./controllers/main/ 

的application.js

//= require jquery 
//= require jquery_ujs 
//= require angular 

回答

1

。在你的main.js.coffe文件中的錯誤。或者更正文件中的語法/代碼錯誤,或者將其從javascript_include_tag(如:<%= javascript_include_tag "application" %>)中刪除。另外,將這個文件包含在application.js中,如果要使用它,將充分利用資產管道......

+0

正確的語法如何查找main.js? – Timsen

+0

好吧,main.js.coffee是一個coffescript文件,所以它必須具有適當的格式和語法。您可能會一眼就發現無效內容,或者可能是像http://www.coffeelint.org/這樣的工具,像RubyMine這樣的好編輯通常會爲您突出顯示錯誤。否則,將其全部刪除並開始將其添加回來,直到您添加提供錯誤的行爲止...... –

+0

第一行是縮進的,可能會導致該錯誤,但您可能不需要該文件和application.js。 .. –