-
Notifications
You must be signed in to change notification settings - Fork 7
/
init.rb
27 lines (22 loc) · 875 Bytes
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'yaml'
db_config = File.open(File.join(RAILS_ROOT, 'config/database.yml'), 'r') {|f|
YAML.load(f)
}
db_config = db_config[RAILS_ENV]
if db_config['adapter'] == 'mongo'
begin
require 'mongo'
rescue
require 'mongo'
end
require 'mongo_record/pk_factory'
$db = Mongo::Connection.new(db_config['host'], db_config['port']).db(db_config['database'], :pk => MongoRecord::PKFactory.new)
# require this after the DB is set up, otherwise ActiveRecord::Base.connection.db does not
# get populated
require 'mongo_record'
# Uncomment the following to log to Mongo using a capped collection.
# require 'logger'
# require 'mongo_record/log_device'
# # Default LogDevice capped collection size is 10 Mb.
# RAILS_DEFAULT_LOGGER = Logger.new(MongoRecord::LogDevice.new("rails_log_#{ENV['RAILS_ENV']}")) unless defined?(RAILS_DEFAULT_LOGGER)
end