加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-4 – Rails coffeescript:TypeError:Object不支

发布时间:2020-12-16 20:48:48 所属栏目:百科 来源:网络整理
导读:我有以下rails配置: Windows 7Rails 4.1.1Ruby 2.0.0p481Gem: coffee-rails 4.0.1Gem: coffee-script 2.3.0Gem: coffee-script-source 1.9.1 我有一个工作正常,但现在没有.我不记得改变什么(git diff没有透露任何东西).我得到的错误是: TypeError: Object
我有以下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文件会产生相同的错误.

我在StackOverflow上看到了一些看起来非常相似的帖子,但在阅读完它们之后,我找不到问题的根本原因,也无法解决它而不只是摆脱.coffee文件.我怀疑这里的CoffeeScript功能设置有些不太正确,但不确定是什么原因似乎安装了正确的宝石.

有人建议可能导致此错误的原因是什么?

解决方法

根据 this,CoffeeScript与Windows不兼容.您可能希望尝试降级CoffeeScript版本或将其从Gemfile中完全删除.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读