Ruby - Test whether database connection is possible -
i looking implement way test database connection our application.
we having connectivity issues , therefore want able check connectivity without having login.
is there way display page stating database connection or database connection down dependent upon whether connection fails. if additional information needed please let me know.
only beginning learn ropes apologies if i'm short on detail.
you can check if connection possible running following script:
require './config/environment.rb' # assuming script located in root of rails app begin activerecord::base.establish_connection # establishes connection activerecord::base.connection # calls connection object puts "connected!" if activerecord::base.connected? puts "not connected!" unless activerecord::base.connected? rescue puts "not connected!" end
Comments
Post a Comment