Rails教程演示应用程序中的ExecJS :: ProgramError

我正在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:  4: DemoApp 5:  "all" %> 6:  7:  8:  9:  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 我正在运行ruby 1.9.3,rails 3.2.7,osx 10.5.8页面呈现

你需要查看你的Gemfile。 找到这一行并取消注释。

 # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby 

我遇到过类似的问题。 我已经安装了node.js并添加了ruby的路径并且工作正常。

在我的情况下, 这是解决方案:我刚刚修改了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' 

如果您正在使用Windows,这肯定有效:

在/app/views/layouts/application.html.erb第5行和第6行中,将第一个参数应用程序更改为默认值。

我遇到了同样的问题,对于我的情况,我不知道为什么,但它只发生在Windows上。 参数应用程序适用于Web服务器。

对于Windows:

在/app/views/layouts/application.html.erb第5行和第6行中,将第一个参数应用程序更改为默认值。

我也遇到了同样的问题,

它帮助我:改变’默认’的’应用’

我的代码:

     AppSample <%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'default', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %>   <%= yield %>