I want to execute some SQL after the connection has been established (for
example `SELECT set_limit(0.2)` to set the trigram match threshold in
PostgreSQL). I'm looking for something like after_connect hook but haven't
found one.

I could monkey-patch Active Record but I'd prefer a more elegant solution.
I could execute the code from an initializer but it won't work if the
connection needs to be reestablished.

My question is: what's the best way to execute a piece of code for each
newly established Active Record connection?

Best regards
Greg Navis
I help tech companies to scale Heroku-hosted Rails apps.
Free, biweekly scalability newsletter for SaaS CEOs

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt84U5xtPf4B%2BBDzQ-RhYkDTE-RiLuZnV_Y1Np6Wd6qCLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouprubyonrails-talk @
postedJun 3, '16 at 9:23a
activeJun 3, '16 at 9:23a

1 user in discussion

Greg Navis: 1 post



site design / logo © 2021 Grokbase