为什么Rails演示应用程序提供“未初始化的常量ExecJS :: RubyRacerRuntime :: Context :: V8”?

作为Rails的新手,我正在尝试启动并运行一个基本的“hello world”应用程序。 特别是Agile Web Development with Rails第2章中的应用程序。 加载hello world页面会导致标题中给出错误。


到目前为止,我已经完成了以下工作:

rails new demo cd demo 

ExecJS抱怨没有可用的JavaScript运行时之后,向Gemfile添加了gem 'therubyracer'

 bundle install rake about # (see below) rails generate controller Say hello goodbye rails server 

此时WEBrick启动并加载http://localhost:3000/say/hello 。 WEBrick记录以下错误(也出现在浏览器中):

 Started GET "/say/hello" for 127.0.0.1 at 2012-10-26 11:45:10 -0400 Connecting to database specified by database.yml Processing by SayController#hello as HTML Rendered say/hello.html.erb within layouts/application (80.9ms) Completed 500 Internal Server Error in 167ms ActionView::Template::Error (uninitialized constant ExecJS::RubyRacerRuntime::Context::V8 (in /home/error/work/demo/app/assets/javascripts/say.js.coffee)): 3:  4: Demo 5:  "all" %> 6:  7:  8:  9:  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___1746644185114933585_70069037653480' Rendered /home/error/.gem/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (3.7ms) Rendered /home/error/.gem/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.2ms) Rendered /home/error/.gem/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (18.7ms) [2012-10-26 11:45:12] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 

rake about回报的rake about

 About your application's environment Ruby version 1.9.3 (x86_64-linux) RubyGems version 1.8.24 Rack version 1.4 Rails version 3.2.8 JavaScript Runtime therubyracer (V8) Active Record version 3.2.8 Action Pack version 3.2.8 Active Resource version 3.2.8 Action Mailer version 3.2.8 Active Support version 3.2.8 Middleware ActionDispatch::Static, Rack::Lock, #, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport Application root /home/error/work/demo Environment development Database adapter sqlite3 Database schema version 0 

工作站正在运行Fedora 17 x86_64。 尽管如此,我几乎忽略了yum存储库中的ruby gem(我认为),并在我的主目录中使用gem install来获取我需要的一切。 (再一次,我想。)

作为Ruby和Rails的新手,我很确定我错过了一些我还没有意识到的明显惯例。 我也不太确定我可能需要提供哪些其他信息,所以请让我知道。

请试试这个:

 sudo apt-get install nodejs 

rubytheracer和nodejs都是javascript库。 这些天大多数人都在寻找nodejs。