6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/herdst_worker/adapters/database.rb', line 6
def self.setup(app)
begin
db_config = app.config_for(:database)
if app.config.is_dev?
ActiveRecord::Base.logger = app.logger.activerecord
end
ActiveRecord::Base.default_timezone = :utc
ActiveRecord::Base.establish_connection(
adapter: db_config[:adapter],
encoding: db_config[:encoding],
charset: db_config[:charset],
collation: db_config[:collation],
pool: db_config[:pool],
host: db_config[:host],
username: db_config[:username],
password: db_config[:password],
database: db_config[:database]
)
ActiveRecord::Base.connection.enable_query_cache!
rescue Exception => ex
app.logger.error ex.message
end
end
|