-
-
Save JoshvaR88/83e88235e32f320619f3 to your computer and use it in GitHub Desktop.
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
# place in config/initalizers | |
module ActiveRecord | |
class Base | |
# Establishes a connection to the database that's used by all Active Record objects. | |
def self.mysql2_connection(config) | |
config[:username] = 'root' if config[:username].nil? | |
if Mysql2::Client.const_defined? :FOUND_ROWS | |
config[:flags] = Mysql2::Client::FOUND_ROWS | Mysql2::Client::MULTI_STATEMENTS | |
end | |
client = Mysql2::Client.new(config.symbolize_keys) | |
options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0] | |
ConnectionAdapters::Mysql2Adapter.new(client, logger, options, config) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment