Ganesh Prasad
1 min readAug 10, 2020

--

Test a new database connection from ruby on rails console

Sometimes we want to test a new database connection from rails console mainly to see if firewall is blocking it or not.

Test: ActiveRecord::Base.establish_connection

Run the following with correct details on rails console

ActiveRecord::Base.establish_connection(
{ :adapter => ‘postgresql’,
:database => ‘database_name’,
:host => ‘x.x.x.x’,
:username => ‘username’,
:password => “username” }
)

Try to access any rails model and create some test records.

--

--