ruby-on-rails – 执行’rails s’时的NameError

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 执行’rails s’时的NameError前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我为Rails开始了这个教程.我刚刚创建了应用程序,并打算测试默认的欢迎页面,这发生了:
D:\Programming\Rails Projects\simpleCMS>rails server
    C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.3/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.3/lib/action_view/helpers.rb:4:in `<module:ActionView>'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.3/lib/action_view/helpers.rb:3:in `<top (required)>'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.3/lib/action_view/base.rb:5:in `require'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/actionview-4.2.3/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 D:/Programming/Rails Projects/simpleCMS/config/application.rb:7:in `<top (required)>'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:78:in `require'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.3/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.3/lib/rails/commands/commands_tasks.rb:75:in `tap'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `server'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
            from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
            from bin/rails:4:in `require'
            from bin/rails:4:in `<main>'

我的gemfile(没有评论):

source 'https://rubygems.org'
gem 'rails','4.2.3'
gem 'MysqL2'
gem 'jbuilder','~> 2.0'
gem 'sdoc','~> 0.4.0',group: :doc
group :development,:test do
    gem 'byebug'
    gem 'web-console','~> 2.0'
end
gem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]

解决方法

卸载railties gem,因为只卸载rails gem不起作用.然后安装一个旧版本的rails gem(在我的情况下为4.0.0,因为那是来自tutotial的那个).

解决了这个问题.

原文链接:https://www.f2er.com/ruby/273901.html

猜你在找的Ruby相关文章