未初始化的常量ActionController :: Routing(NameError)

时间:2015-06-12 22:09:51

标签: ruby-on-rails web-deployment ruby-on-rails-4.2

尝试在linux服务器上部署我的应用程序时出现此错误。

Versãoservidor:x86_64-pc-linux-gnu上的PostgreSQL 9.3.4,由x86_64-pc-linux-gnu-gcc编译(Gentoo 4.8.1-r1 p1.2,pie-0.5.7)4.8.1 ,64位

    uninitialized constant ActionController::Routing (NameError)
  /home/divulgapocos/apps_rails/divulgapocos/config/initializers/new_rails_defaults.rb:14:in `<top (required)>'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:652:in `block in load_config_initializer'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:166:in `instrument'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:651:in `load_config_initializer'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:615:in `each'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/engine.rb:615:in `block in <class:Engine>'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `instance_exec'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:30:in `run'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:55:in `block in run_initializers'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:209:in `block in each_strongly_connected_component_from'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `each'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:44:in `tsort_each_child'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:203:in `each_strongly_connected_component_from'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  /opt/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/initializable.rb:54:in `run_initializers'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/application.rb:352:in `initialize!'
  /home/divulgapocos/apps_rails/divulgapocos/config/environment.rb:5:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.6.1/lib/rack/builder.rb:55:in `instance_eval'
  /opt/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/rack-1.6.1/lib/rack/builder.rb:55:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /opt/apx_passenger//helper-scripts/rack-preloader.rb:112:in `eval'
  /opt/apx_passenger//helper-scripts/rack-preloader.rb:112:in `preload_app'
  /opt/apx_passenger//helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /opt/apx_passenger//helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /opt/apx_passenger//helper-scripts/rack-preloader.rb:28:in `<main>'

My Gemfile看起来像这样

source 'https://rubygems.org'

gem 'rails', '4.2.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem "paperclip", "~> 4.2"
gem 'devise'
gem 'pg'
gem 'bootstrap-sass', '~> 3.3.4'
gem 'autoprefixer-rails'
gem 'masonry-rails', '~> 0.2.4'
gem 'devise-bootstrap-views'
gem 'paypal-recurring'
gem 'therubyracer'
gem 'activesupport'
gem 'railties'
gem 'rack'


group :development, :test do

  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'

end

1 个答案:

答案 0 :(得分:0)

您已从较旧的2.x版Rails更新此应用。您的config/initializers/new_rails_defaults.rb中有一行使用ActionController::Routing常量,Rails 4.2中不再存在该常量。

所以,基本上,这里的修复是将您的应用程序正确升级到4.2。我可以告诉你从你的文件中删除ActionController::Routing行,但这可能只是你在这里没有解决的许多其他问题之一。

这里奇怪的是你没有提到在开发中遇到同样的问题,这表明你实际上并没有使用你认为自己的开发版Rails。

祝你好运。