This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |