2

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?

Jared Beck
  • 16,796
  • 9
  • 72
  • 97

1 Answers1

3

The solution seems to be to disconnect the gateway connection.

on_worker_boot do
  ROM.env.gateways[:default].connection.disconnect
end
Jared Beck
  • 16,796
  • 9
  • 72
  • 97