Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andy9775/582fb872184666dd184ccb8cd5b250d7 to your computer and use it in GitHub Desktop.
Save andy9775/582fb872184666dd184ccb8cd5b250d7 to your computer and use it in GitHub Desktop.
ActiveRecord callback when connection is made

The ConnectionAdapter defines two callbacks :checkout (connect) and :checkin (disconnect).

ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.set_callback :checkout, :after do
  raw_connection
end

Source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment