6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/herdst_worker/adapters/database.rb', line 6
def self.setup(app)
ActiveRecord::Base.default_timezone = :utc
begin
if app.config.is_dev?
ActiveRecord::Base.logger = app.logger.activerecord
end
db_config = app.config_for(:database)
db_config.each do |k, v|
db_config[k] = ActiveRecord::DatabaseConfigurations::HashConfig.new(app.config.env, k, v)
end
ActiveRecord::Base.configurations = db_config.values
ActiveRecord::Base.establish_connection(db_config[:primary])
ActiveRecord::Base.connection.enable_query_cache!
rescue Exception => ex
app.logger.error ex.message
end
end
|