Skip to content

Instantly share code, notes, and snippets.

@tbaba
Last active September 7, 2018 07:55
Show Gist options
  • Save tbaba/10bba47881bf54c0191f220460c9e3f1 to your computer and use it in GitHub Desktop.
Save tbaba/10bba47881bf54c0191f220460c9e3f1 to your computer and use it in GitHub Desktop.

establish_connection


[57, 66] in /usr/local/var/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb
   57:       spec = resolver.resolve(config).symbolize_keys
   58:       spec[:name] = spec_name
   59: 
   60:       byebug
   61: 
=> 62:       connection_handler.establish_connection(spec)
   63:     end
   64: 
   65:     class MergeAndResolveDefaultUrlConfig # :nodoc:
   66:       def initialize(raw_configurations)
[55, 64] in /usr/local/var/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/core.rb
   55:       end
   56:       self.configurations = {}
   57: 
   58:       # Returns fully resolved configurations hash
   59:       def self.configurations
=> 60:         @@configurations
   61:       end
   62: 
   63:       ##
   64:       # :singleton-method:
(byebug) @@configurations
{"default"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000}, "development"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/development.sqlite3"}, "test"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/test.sqlite3"}, "production"=>{"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/production.sqlite3"}}
[128, 137] in /usr/local/var/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb
   128:     def remove_connection(name = nil)
   129:       name ||= @connection_specification_name if defined?(@connection_specification_name)
   130:       # if removing a connection that has a pool, we reset the
   131:       # connection_specification_name so it will use the parent
   132:       # pool.
=> 133:       if connection_handler.retrieve_connection_pool(name)
   134:         self.connection_specification_name = nil
   135:       end
   136: 
   137:       connection_handler.remove_connection(name)
(byebug) @connection_specification_name
"primary"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment