From ab688e09c0f668e66beeb2dd4a39086f2ac19f86 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 21 Nov 2022 14:51:20 +0100 Subject: [PATCH] Execute SQL statement in ping controller --- app/controllers/ping_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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