2
C:\Users\Clarion Smith\Documents\Sites\simple_cms>rails server 
C:/Ruby22/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/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:4:in `<module:ActionView>' 
     from C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionview-4.2.4/lib/action_view/helpers.rb:3:in `<top (required)>' 
     from C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionview- 

我的问题在Ruby和Rails中很常见。虽然我经历了不同的stackoverflow答案,但我找不到任何具体的问题来解决我的错误。actionview-4.2.4 - 未初始化的常量ActionView :: Helpers :: ActiveModelHelper(NameError)

我试着重新安装较低版本的铁轨宝石,但同样的错误不断弹出。我试图重新安装所有抛出错误的宝石,但问题仍然没有消失。许多文章指出这是一个兼容性问题。但是当我尝试重新安装railties gem(4.0.0)的较低版本时,命令提示仍然要求我升级到最新版本才能继续。我还安装了'乘客'网络服务器来检查兼容性和类似的错误弹出,但这次与乘客宝石。请相应地调查一下。我也在复制下面的宝石文件。

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.2.4' 
# Use mysql as the database for Active Record 
gem 'mysql2' 
#Bundle for Passenge r web server 
gem 'passenger' 
# Use SCSS for stylesheets 
#gem 'sass-rails', '~> 5.0' 
# Use Uglifier as compressor for JavaScript assets 

#gem 'uglifier', '>= 1.3.0' 
gem 'rack', '~> 1.6.0' 
gem 'rspec-rails', :group => [:development, :test] 
# Use CoffeeScript for .coffee assets and views 

#gem 'coffee-rails', '~> 4.1.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' 
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 

#gem 'turbolinks' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 

#gem 'jbuilder', '~> 2.0' 
# bundle exec rake doc:rails generates the API under doc/api. 

#gem 'sdoc', '~> 0.4.0', group: :doc 

# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# Use Unicorn as the app server 
# gem 'unicorn' 

# Use Capistrano for deployment 
# gem 'capistrano-rails', group: :development 

group :development, :test do 
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
    gem 'byebug' 
end 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %> in views 
    gem 'web-console', '~> 2.0' 
end 

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 

回答

1

我记得修复这个错误是这样的:

  1. 卸载railties宝石。

  2. 然后(在我的情况4.0.0,因为这是从教程中的一个)安装rails宝石的旧版本。

这使我解决了这个问题一次。

你试过这些步骤吗?

+0

@K中号Rakibul伊斯兰 - 我想这一点。但我得到的问题是命令提示符不允许我运行rails,直到我将其升级到最新版本的4.2.2。我正在粘贴下面的代码片段。 C:\ Users \ Clarion Smith \ Documents \ Sites \ simple_cms> rails server 无法在任何源中找到railties-4.2.4 运行'bundle install'安装缺失的gem。我运行软件包安装,并更新到4.2.4(最新版本自动)。 –

+0

嗯,好像事情已经改变了。你能分享你正在关注的教程链接吗? –

+0

https://www.youtube.com/watch?v=WEjkWRbLS84&index=4&list=PL5bVh07ELMxT8OsaX01SjpqmsWCk-eHtp –

1

检查您的Gemfile.lock文件中是否使用了nokogiri的版本。我遇到了与nokogiri 1.6.6.4相同的问题。它使用必要的dll成功安装,但由于某些原因,它在Windows上播放效果不佳。

什么对我来说工作,希望这个作品对你来说太

  1. gem 'nokogiri', '1.6.6.2'在宝石文件
  2. 卸载引入nokogiri
  3. 下载引入nokogiri的其他版本1.6.6.2宝石从here通过编译paulgrant999 for ruby​​ 2.2。目前,x86和x64版本都可用。作者状态回购即将被删除。
  4. 使用命令安装gem install --local path-to-gem/filename.gem
  5. 捆绑安装在您的项目目录中。它可能会要求您运行bundle update nokogiri以更新依存关系。 rails s现在应该启动服务器。
1

对我来说,我是能够解决这个问题有

gem pristine --all 
相关问题