How to configure puma to establish rom-rb database connection?

455 Views Asked by At

If I were using ActiveRecord, my puma config would establish the database connection as described in Heroku's guide Deploying Rails Applications with the Puma Web Server.

on_worker_boot do
  ActiveRecord::Base.establish_connection
end

However, I am using ROM (Ruby Object Mapper).

I tried omitting the on_worker_boot block, but (predictably) the database connection is either not established, or is not established correctly, and the following error is raised.

PG::ConnectionBad: PQconsumeInput() SSL error: decryption failed or bad record mac

I've read the ROM Setup Guide but did not see anything relevant.

How do I establish the ROM connection in puma?

1

There are 1 best solutions below

0
On

The solution seems to be to disconnect the gateway connection.

on_worker_boot do
  ROM.env.gateways[:default].connection.disconnect
end