Rails 4 Unicorn Serve App Without ActiveRecord

可紊 提交于 2019-12-11 04:48:37

问题


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?


回答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"


来源:https://stackoverflow.com/questions/17960473/rails-4-unicorn-serve-app-without-activerecord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!