在rails 3.2中使用javascript而不使用coffeescript

ben*_*_an 5 javascript coffeescript ruby-on-rails-3

我正在使用Rails 3.2,它是为coffeescript设置的.我知道Coffeescript是一种很棒的语言,并不是很难学,但我只是开始围绕Javascript和jQuery.所以我的问题是:有没有一种简单的方法来设置rails 3.2以使用Javascript代替?目前,我的jQuery是<script></script>在我的视图中的标签(timeline/index.html.erb).我想将它移动到.js文件中.我尝试将timeline.js.coffee的名称更改为timeline.js并将jQuery放在那里,但我明白了Uncaught SyntaxError: Unexpected token ILLEGAL.

除了"学习coffeescript"的明显答案外,我该怎么办?

ben*_*_an 6

我走在正确的轨道上.要在rails 3.2中切换到javascript,您只需要删除.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://jashkenas.github.com/coffee-script/
Run Code Online (Sandbox Code Playgroud)