为什么 Rails 演示应用程序给出“未初始化的常量 ExecJS::RubyRacerRuntime::Context::V8"? [英] Why does Rails demo app give "uninitialized constant ExecJS::RubyRacerRuntime::Context::V8"?

查看:33
本文介绍了为什么 Rails 演示应用程序给出“未初始化的常量 ExecJS::RubyRacerRuntime::Context::V8"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Being new to Rails, I'm trying to get a basic "hello world" app up and running. Specifically the app in chapter 2 of Agile Web Development with Rails. Loading up the hello world page results in the error given in the title.

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

So far I've done the following:

rails new demo
cd demo

ExecJS 抱怨没有可用的 JavaScript 运行时后,将 gem 'therubyracer' 添加到 Gemfile.

Added gem 'therubyracer' to the Gemfile after ExecJS complained about no JavaScript runtime being available.

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

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

At this point WEBrick fires up and I load up http://localhost:3000/say/hello. WEBrick logs the following error (which also appears in the browser):

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: <head>
    4:   <title>Demo</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___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 返回:

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, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x0000000276b298>, 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 来获取我需要的一切.(再次,我认为.)


The workstation is running Fedora 17 x86_64. Despite that, I've pretty much ignored the ruby gems in the yum repositories (I think) and used gem install in my home directory to get everything I need. (Again, I think.)

作为 Ruby 和 Rails 的新手,我很确定我错过了一些我尚未意识到的明显约定.我也不太确定我可能需要提供哪些额外信息,所以也请告诉我.

Being new to Ruby and Rails, I'm pretty sure I've missed some obvious convention that I'm not yet aware of. I'm also not quite sure what additional information I might need to provide, so please let me know that as well.

推荐答案

请试试这个:

sudo apt-get install nodejs

rubytheracer 和 nodejs 都是 javascript 库.现在大多数人都在使用 nodejs.

rubytheracer and nodejs are both javascript libraries. Most folks are going for nodejs these days.

这篇关于为什么 Rails 演示应用程序给出“未初始化的常量 ExecJS::RubyRacerRuntime::Context::V8"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆