未初始化的常量 ActionController::Routing (NameError) [英] uninitialized constant ActionController::Routing (NameError)

查看:32
本文介绍了未初始化的常量 ActionController::Routing (NameError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Linux 服务器上部署我的应用程序时遇到此错误.

I am getting this error when trying to deploy my application on a linux server.

Versão servidor: PostgreSQL 9.3.4 on x86_64-pc-linux-gnu, 编译 x86_64-pc-linux-gnu-gcc (Gentoo 4.8.1-r1 p1.2, pie-0.5.7) 4.8.1, 64 位

Versão servidor: PostgreSQL 9.3.4 on x86_64-pc-linux-gnu, compiled by x86_64-pc-linux-gnu-gcc (Gentoo 4.8.1-r1 p1.2, pie-0.5.7) 4.8.1, 64-bit

    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>'

我的 Gemfile 看起来像这样

My Gemfile looks like this

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

推荐答案

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

You've updated this app from an older, 2.x version of Rails. You have a line in your config/initializers/new_rails_defaults.rb that uses the ActionController::Routing constant, that constant no longer exists in Rails 4.2.

所以,基本上,这里的解决方法是将您的应用正确升级到 4.2.我可以告诉您从文件中删除 ActionController::Routing 行,但这可能只是您在此处未解决的许多其他问题之一.

So, basically, the fix here is to upgrade your app to 4.2 properly. I could tell you to remove the ActionController::Routing line from your file, but probably that's just one of many other issues you haven't fixed here.

奇怪的是,您没有提到在 dev 中存在同样的问题,这表明您实际上并没有在 dev 中使用您认为的 Rails 版本.

The weird thing here is that you haven't mentioned having the same problems in dev, which suggests you're not actually using the version of Rails in dev that you think you are.

祝你好运.

这篇关于未初始化的常量 ActionController::Routing (NameError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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