Execute SQL statement in ping controller

This commit is contained in:
Sebastian Serth
2022-11-21 14:51:20 +01:00
parent 25707478ea
commit ab688e09c0

View File

@ -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