Rails coffeescript : TypeError: Object doesn't support this property or method

Rails coffeescript : TypeError: Object doesn't support this property or method

我有以下 rails 配置:

Windows 7
Rails 4.1.1
Ruby 2.0.0p481
Gem: coffee-rails 4.0.1
Gem: coffee-script 2.3.0
Gem: coffee-script-source 1.9.1

我有一个运行良好的应用程序,但现在不行了。我不记得有任何更改(git diff 没有显示任何内容)。我得到的错误是:

TypeError: Object doesn't support this property or method
  (in c:/Users/mbratc01/Documents/Rails/manpower/app/assets/javascripts/welcome.js.coffee)

Extracted source (around line #9):
 7 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => false %>
 8 <%= javascript_include_tag 'jquery-1.11.1', 'data-turbolinks-track' => false %>
 9 <%= javascript_include_tag 'application', 'data-turbolinks-track' => false %>
10 <%= csrf_meta_tags %>
11 </head>

我真的没有正在进行的 Coffeescript 项目。 welcome.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/

我发现如果我将这个文件移动到另一个无法访问的位置,应用程序运行正常。此外,在 app/assets/javascript 文件夹中仅放置一个空的 .coffee 文件会产生与上述相同的错误。

我在 Whosebug 上看到了几篇看起来非常相似的帖子,但在通读它们之后,我找不到问题的根本原因,也无法解决问题而不只是摆脱 .coffee 文件。我怀疑这里的 CoffeeScript 功能设置不太正确,但不确定似乎安装了正确的 gem。

有人对导致此错误的原因有任何建议吗?

根据 ,CoffeeScript 在 Windows 下运行不佳。您可能想尝试降级 CoffeeScript 的版本或将其从 Gemfile 中完全删除。

然后只需将 .coffee 文件重命名为普通 .js 并在您的 Rails 应用程序中摇滚常规 javascript。

我认为重命名扩展名不是好的解决方案。尝试以下操作:

添加到 Gemfile

gem 'coffee-script-source', '1.8.0'

然后,运行

bundle update coffee-script-source

并重启服务器(如果需要)