Rails verwendet Connection Pooling, daher ist es am besten, eine alias_method_chain für ActiveRecord::ConnectionAdapters::ConnectionPool#new_connection
zu verwendenmodule ActiveRecord
Module ConnectionAdapters
class ConnectionPool
alias_method_chain :new_connection, :my_stuff
private
def new_connection_with_my_stuff
c = new_connection_without_my_stuff
# Do your stuff with
# c.exec(<your sql command>)
c
end
end
end
end