Rails rails 4.0.2 PG::UnableToSend: SSL SYSCALL error: EOF detected

liker · 2014年06月23日 · 3140 次阅读

数据库为 MySQL,但是需要引入第二个数据库 PG database.yml

production:
  template: template0
  host: ******
  port: ****
  adapter: mysql2
  database: ********
  pool: 5
  username: ***
  password: ***

pacs_system:
  host: ********
  port: ****
  adapter: postgresql
  encoding: unicode
  database: *********
  pool: 5
  username: ******
  password: ***

model/pacs_user.rb

class PacsUser < ActiveRecord::Base
  attr_accessible :pk, :created_time......
  self.table_name = "patient"
  has_many :pacs_studies, :dependent => :destroy, foreign_key: :user_fk
  establish_connection "pacs_system"
end

部署之后产生如下错误

ERROR -- : PG::UnableToSend: SSL SYSCALL error: EOF detected

http://www.ruby-railings.com/en/rails/postgresql/2014/01/11/connection-problems-in-rails-4.html https://github.com/rails/rails/issues/12867 创建 initializers/ar.rb

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter
      def active?
        @connection.query 'SELECT 1'
        true
      rescue PGError
        false
      end
    end
  end
end

报未连接的错误

ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)

求大神帮忙看看

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号