diff --git a/app/controllers/ping_controller.rb b/app/controllers/ping_controller.rb index 8ba2a7ad..70a4d6da 100644 --- a/app/controllers/ping_controller.rb +++ b/app/controllers/ping_controller.rb @@ -16,8 +16,8 @@ class PingController < ApplicationController def postgres_connected! # any unhandled exception leads to a HTTP 500 response. - ApplicationRecord.establish_connection - ApplicationRecord.connection - raise ActiveRecord::ConnectionNotEstablished unless ApplicationRecord.connected? + return if ApplicationRecord.connection.execute('SELECT 1 as result').first['result'] == 1 + + raise ActiveRecord::ConnectionNotEstablished end end