2016-12-15 86 views
4

我想让我的项目的视图显示出来。但我得到这个错误:如何解决模板错误“CoffeeScript未定义”

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,和“Ruby 2.3.3p222(2016-11-21修订版56859)[x86_64-darwin16]”。另外我正在使用Mac OS Sierra。

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

我也有我的看法和控制器设置,这就是为什么它工作时,我删除线7-8。

这是我的宝石文件:

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] 
+0

Postgres与它无关,它是一个作为完全独立应用程序运行的数据库管理器。 –

回答

6

有一个在咖啡脚本代码宝石1.12.1这是最近更新的问题。问题是该版本中的源文件是空的。已经有一个open issue,它应该很快就会被修复。

现在你可以添加到您的Gemfile

gem 'coffee-script-source', '= 1.11.1' 

和运行bundle update coffee-script-source,直到它的固定。

+1

非常感谢。 – pkayokay

+1

希望我可以不止一次地对此赞赏!太令人沮丧了! – Sprachprofi

0

我也不得不使用gem uninstall coffee-script-source,然后gem install coffee-script-source ......我的Gemfile.lock的未更新,无论有多少次我都删除咖啡脚本&咖啡脚本后,“包安装”或“包更新” gemfile中的源条目。

相关问题