Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/configurations.rb

Class Method Summary collapse

Class Method Details

.establish_connection(config = nil) ⇒ Object

This is a quick hack to work around github.com/rails/rails/pull/32135



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_record/configurations.rb', line 29

def self.establish_connection(config = nil)
  raise "Anonymous class is not allowed." unless name
  
  config ||= DEFAULT_ENV.call.to_sym
  spec_name = self == Base ? "primary" : name
  self.connection_specification_name = spec_name
  
  resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(self.configurations)
  spec = resolver.resolve(config).symbolize_keys
  spec[:name] = spec_name
  
  connection_handler.establish_connection(spec)
end