Skip to content

Instantly share code, notes, and snippets.

@ostinelli
Last active July 6, 2018 01:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ostinelli/fe514da99d3ea80fbd801890bbd0ee35 to your computer and use it in GitHub Desktop.
Save ostinelli/fe514da99d3ea80fbd801890bbd0ee35 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