我正在关注http://ruby.railstutorial.org/chapters/a-demo-app#sec:planning_the_application上的演示应用教程。为用户生成脚手架后。当我尝试访问localhost:3000 / users。我在ExecJS上遇到以下错误
Started GET "/users" for 127.0.0.1 at 2012-08-01 13:35:37 -0500
Connecting to database specified by database.yml
Processing by UsersController#index as HTML
User Load (0.1ms) SELECT "users".* FROM "users"
Rendered users/index.html.erb within layouts/application (3.1ms)
Completed 500 Internal Server Error in 458ms
ActionView::Template::Error (ExecJS::ProgramError
(in /Users/kylec/apps/demo_app/app/assets/javascripts/users.js.coffee)):
3: <head>
4: <title>DemoApp</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___642905557_18993590'
app/controllers/users_controller.rb:7:in `index'
如果我拿出#line 6&lt;%= javascript_include_tag“应用程序”%&gt;该页面呈现 我正在运行ruby 1.9.3,rails 3.2.7,osx 10.5.8
答案 0 :(得分:1)
你需要查看你的Gemfile。找到这一行并取消注释。
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
答案 1 :(得分:1)
我遇到过类似的问题。 我已经安装了node.js并添加了ruby的路径,但它确实有效。
答案 2 :(得分:1)
就我而言this was the solution: 我刚修改了gemfile,将coffee-script-source降级为1.8.0,瞧!这是我的gemfile:
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# Downgrade coffee-script source
gem 'coffee-script-source', '~>1.8.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
答案 3 :(得分:0)
如果您正在使用Windows,这肯定有效:
在/app/views/layouts/application.html.erb第5行和第6行中,将第一个参数应用程序更改为默认值。
我也遇到了同样的问题,对于我的情况,我不知道为什么,但它只发生在Windows上。参数应用程序适用于Web服务器。
答案 4 :(得分:0)
对于Windows:
在/app/views/layouts/application.html.erb第5行和第6行中,将第一个参数应用程序更改为默认值。
我也遇到了同样的问题,
它对我有所帮助: 改变应用程序&#39;对于&#39;默认&#39;
我的代码:
<!DOCTYPE html>
<html>
<head>
<title>AppSample</title>
<%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'default', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>