uninitialized constant ActionController::Routing (NameError)

2.8k views Asked by At

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

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
1

There are 1 answers

3
smathy On

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.

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.

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.

Good luck.