首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复“未定义的CoffeeScript”模板错误

如何修复“未定义的CoffeeScript”模板错误
EN

Stack Overflow用户
提问于 2016-12-15 21:20:19
回答 2查看 778关注 0票数 4

我正试图为我的项目的出现提供视图。但我知道这个错误:

代码语言:javascript
运行
复制
ActionView::Template::Error (ReferenceError: CoffeeScript is not defined):
4:     <title>Myapp</title>
5:     <%= csrf_meta_tags %>
6:
7:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9:   </head>

10:

当我删除第7-8行时,它就可以工作了,但是我将没有CSS或JavaScript。

大约一周前我没有收到这个错误。我不知道原因是什么。我试过转换Rails版本。我尝试过卸载Postgres并重新设置它,但它似乎不是问题所在。我有Rails 5.0.0.1和“Ruby2.3.3p222 (2016-11-21修订版56859) x8664-darwin16 16”。而且我用的是。

我可以将“应用程序”更改为“默认”,而且它可以工作,但我不明白为什么它在大约一周前起作用,而不是现在。

我还设置了我的视图和控制器,这也是当我删除第7-8行时它工作的原因。

这是我的创业板文件

代码语言:javascript
运行
复制
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-15 21:29:36

最近更新的“咖啡脚本源宝石”1.12.1中存在一个问题。问题是这个版本中的源文件是空的。已经有了一个公开发行,它应该很快就会修复。

现在您可以将它添加到您的GemFile中。

代码语言:javascript
运行
复制
gem 'coffee-script-source', '= 1.11.1'

然后运行bundle update coffee-script-source,直到它修好为止。

票数 6
EN

Stack Overflow用户

发布于 2016-12-16 12:56:23

我还得用gem uninstall coffee-script-source,然后gem install coffee-script-source .因为我的gemfile.lock没有更新,无论我做了多少次‘包安装’或‘包更新’后,删除咖啡-脚本&咖啡-脚本源条目,在did文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41173513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档