【问题标题】:WEBrick rails server is not workingWEBrick rails 服务器不工作
【发布时间】:2015-11-04 18:51:19
【问题描述】:

我的操作系统是 Windows 10

今天我已经安装了 Ruby (ruby 2.2.3p173 (2015-08-18 revision 51636) [x64-mingw32]) 和 rails gem (rails 4.2.4)

我正在关注一系列关于 Rails 的教程视频中的流程。 我安装了以下版本的 myqsl 2(并重新安装,以防它是脏安装)mysql2-0.4.1-x64-mingw32

此问题涉及一个名为 simple_cms 的应用程序,该应用程序按照教程中的说明以下列方式创建

rails new simple_cms -d mysql

我有:

  • 运行捆绑安装几次
  • 使用 gem 清理
  • 运行 bundle exec rails server
  • 尝试 rake db:create 和 bundle exec rake:db 按照建议创建每个方法here
  • 重装mysql2几次

然而在输入

rails server

在我的项目 simple_cms 的根目录中。 WEBrick 甚至无法启动

例如在herehere的其他类似问题中,两个询问者都会收到以下信息

=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

etc ..etc....WEBrick 失败前。但是,我还没有做到这一点,因为没有提到与 WEBrick 有任何关系。以下是我在输入 rails server 命令后收到的错误消息:

simple_cms>rails server
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-     4.2.4/lib/action_view/helpers.rb:40:in `<module:Helpers>': uninitialized constant ActionView::Helpers::ActiveModelHelper (NameError)
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:4:in `<module:ActionView>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:3:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/base.rb:5:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/base.rb:5:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/template.rb:7:in `<class:Template>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/template.rb:6:in `<module:WebConsole>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/template.rb:1:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console.rb:12:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console.rb:12:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web-console.rb:1:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web-console.rb:1:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
    from C:/Users/Lizanne/Documents/Code/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:78:in `require'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

可以做些什么来纠正这种情况,因为我现在在循环中一遍又一遍地尝试同样的事情,正如爱因斯坦正确地指出的那样,精神错乱的定义是一遍又一遍地做同样的事情并期待不同的结果.

我安装了以下 gems

actionmailer (4.2.4) 
actionpack (4.2.4)
actionview (4.2.4)
activejob (4.2.4)
activemodel (4.2.4)
activerecord (4.2.4)
activesupport (4.2.4)
arel (6.0.3)
bigdecimal (1.2.7, 1.2.6)
binding_of_caller (0.7.2)
builder (3.2.2)
bundler (1.10.6)
byebug (6.0.2)
coffee-rails (4.1.0)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
i18n (0.7.0)
io-console (0.4.3)
jbuilder (2.3.2)
jquery-rails (4.0.5)
json (1.8.3, 1.8.1)
loofah (2.0.3)
mail (2.6.3)
mime-types (2.6.2)
mini_portile (0.6.2)
minitest (5.8.2)
multi_json (1.11.2)
mysql2 (0.4.1 x64-mingw32)
nokogiri (1.6.6.2 x64-mingw32)
power_assert (0.2.5)
psych (2.0.15, 2.0.8)
rack (1.6.4)
rack-test (0.6.3)
rails (4.2.4)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.7)
rails-html-sanitizer (1.0.2)
railties (4.2.4)
rake (10.4.2)
rdoc (4.2.0)
sass (3.4.19)
sass-rails (5.0.4)
sdoc (0.4.1)
sprockets (3.4.0)
sprockets-rails (2.3.3)
test-unit (3.1.5)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.1)
turbolinks (2.5.3)
tzinfo (1.2.2)
tzinfo-data (1.2015.7)
uglifier (2.7.2)
web-console (2.2.1)

在此先感谢

【问题讨论】:

  • 如果在新目录下新建项目并启动服务器,是否还会出现此错误? (rails new test_project; bundle install; rake db:create; rails s)
  • 检查已批准answer
  • Kalelc 成功了,你是钻石。 !!!!!!!!!!!! (高兴得跳起来)
  • kalelc 将其放在答案部分而不是评论中,因此我可以将其评为正确。请问在这种情况下,新版本的 rails 和 WEBrick 导致的问题是什么......或者答案是否非常复杂?
  • @Aerosewall1 准备好了 :)

标签: ruby-on-rails ruby-on-rails-3 webrick


【解决方案1】:

检查批准answer

这是railtiesrails gems 版本之间的问题。是的,答案很复杂。对于未来的开发,请尝试为您的项目使用一些版本控制系统 (Rbenv)

【讨论】: