1

I am building a rails 4 app that does not use any database. I have successfully disabled ActiveRecord on my development machine by following a few guides online by deleting database.yml and replacing

require 'rails/all'

with

require "action_controller/railtie"
require "action_mailer/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"

It works locally but when I try to deploy it on the server running unicorn, I get this on the err logs

ERROR -- : ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
/home/rtb/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'

the app worked fine on the production unicorn server when I had a database.yml on and activerecord enabled. Is there something I am missing?

yretuta
  • 7,963
  • 17
  • 80
  • 151

1 Answers1

1

The ConnectionManagement middleware from ActiveRecord is probably still active. This middleware manages the connection pool for each request. It should not be active if you haven't loaded ActiveRecord.

You can manually remove the middleware with the following line in your Rails configuration:

config.app_middleware.delete "ActiveRecord::ConnectionAdapters::ConnectionManagement"
Winfield
  • 18,985
  • 3
  • 52
  • 65