Rails 4独角兽服务器没有ActiveRecord [英] Rails 4 Unicorn Serve App Without ActiveRecord

查看:105
本文介绍了Rails 4独角兽服务器没有ActiveRecord的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个不使用任何数据库的rails 4应用程序。我已经成功地在我的开发机器上禁用了ActiveRecord,通过在线删除database.yml并替换

  require'rails /所有'

 
需要action_controller / railtie
需要action_mailer / railtie
需要rails / test_unit / railtie
需要链轮/轨道

它在本地工作,但是当我尝试在运行独角兽的服务器上部署它时,我得到这个err日志

 错误 - :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:在`retrieve_connection'

当我有一个database.yml和activerecord启用时,应用程序在生产独角兽服务器上工作正常。有没有我缺少的东西?

解决方案

来自ActiveRecord的 ConnectionManagement 可能还是活跃的这个中间件管理每个请求的连接池。如果您没有加载ActiveRecord,它不应该处于活动状态。



您可以使用Rails配置中的以下行手动删除中间件:

  config.app_middleware.deleteActiveRecord :: ConnectionAdapters :: ConnectionManagement


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?

解决方案

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"

这篇关于Rails 4独角兽服务器没有ActiveRecord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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