Skip to content

Instantly share code, notes, and snippets.

View adstage-david's full-sized avatar

David Haslem adstage-david

View GitHub Profile
# Call ActiveRecord::base.forbid_implicit_checkout_for_thread! from a thread, and if
# that thread later tries to access an active record connection without explicit checkout
# (#with_connection, or #checkout), an ImplicitConnectionForbiddenError will be raised.
module ActiveRecord
class Base
class << self
def forbid_implicit_checkout_for_thread!
Thread.current[:active_record_forbid_implicit_connections] = true
end