问题
I'm following demo app tutorial on http://ruby.railstutorial.org/chapters/a-demo-app#sec:planning_the_application. After generate scaffold for users. when i try to access localhost:3000/users. I got the following error on 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'
The page renders if I take out #line 6 <%= javascript_include_tag "application"%> I'm running ruby 1.9.3, rails 3.2.7, osx 10.5.8
回答1:
You need to look in your Gemfile. Find this line and uncomment it.
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
回答2:
I have faced with similar problem. I have installed node.js and add path to ruby and it worked.
回答3:
In my case this was the solution: I just modified gemfile downgrading coffee-script-source to 1.8.0, and voila! Here is my 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'
回答4:
If you are working on windows, this definitely works :
In your /app/views/layouts/application.html.erb line 5 and 6, change the first parameter application to default.
I met the same problem, too for my situation, I don't know why, but it only happen on Windows. The parameter application works on web server.
回答5:
For Windows:
In your /app/views/layouts/application.html.erb line 5 and 6, change the first parameter application to default.
I met the same problem also,
it is helped me: change 'application' for 'default'
my code:
<!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>
来源:https://stackoverflow.com/questions/11765611/execjsprogramerror-in-rails-tutorial-demo-app