2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
require "active_support/logger"
|
|
|
|
require "models/college"
|
|
|
|
require "models/course"
|
|
|
|
require "models/professor"
|
2016-12-14 06:14:47 -05:00
|
|
|
require "models/other_dog"
|
2011-06-04 18:19:17 -04:00
|
|
|
|
|
|
|
module ARTest
|
2011-06-05 06:28:02 -04:00
|
|
|
def self.connection_name
|
2016-08-06 12:26:20 -04:00
|
|
|
ENV["ARCONN"] || config["default_connection"]
|
2011-06-05 06:28:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.connection_config
|
2017-02-27 09:22:56 -05:00
|
|
|
config.fetch("connections").fetch(connection_name) do
|
|
|
|
puts "Connection #{connection_name.inspect} not found. Available connections: #{config['connections'].keys.join(', ')}"
|
|
|
|
exit 1
|
|
|
|
end
|
2011-06-05 06:28:02 -04:00
|
|
|
end
|
|
|
|
|
2011-06-04 18:19:17 -04:00
|
|
|
def self.connect
|
2012-03-01 22:10:06 -05:00
|
|
|
puts "Using #{connection_name}"
|
2012-10-26 10:51:02 -04:00
|
|
|
ActiveRecord::Base.logger = ActiveSupport::Logger.new("debug.log", 0, 100 * 1024 * 1024)
|
|
|
|
ActiveRecord::Base.configurations = connection_config
|
2013-12-24 04:18:54 -05:00
|
|
|
ActiveRecord::Base.establish_connection :arunit
|
|
|
|
ARUnit2Model.establish_connection :arunit2
|
2011-06-04 18:19:17 -04:00
|
|
|
end
|
|
|
|
end
|