.js.coffee文件未在rails app中运行

时间:2013-01-12 16:48:36

标签: jquery ruby-on-rails

我正在尝试根据#381 railscast一集运行一个简单的javascript文件。但是,当我在我的javascript文件中发出警报时,当我加载页面时它不会出现。我确信在我查看视图源时加载了文件本身。任何想法为什么它没有加载?

的application.js:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery-fileupload/basic
//= require jquery-fileupload/vendor/tmpl
//= require js-routes
//= require twitter/bootstrap
//= requre_self
//= require_tree .

images.js.coffee:

jQuery ->
  alert("hello world")
  $('#new_image').fileupload
    dataType: "script"

1 个答案:

答案 0 :(得分:2)

尝试从application.js中删除导致JS错误的文件。您还可以尝试删除递归包含app / assets / javascripts中所有文件的require_tree .,但如果您这样做,则必须手动添加所有需要包含的文件。