Class: C3s::DatabaseAdapter
- Inherits:
-
Object
- Object
- C3s::DatabaseAdapter
- Defined in:
- lib/databaseadapter.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ DatabaseAdapter
constructor
A new instance of DatabaseAdapter.
Constructor Details
#initialize(config) ⇒ DatabaseAdapter
Returns a new instance of DatabaseAdapter.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/databaseadapter.rb', line 5 def initialize(config) log_file = File.join(C3S_LOG_DIR, "database.log") db_file = File.join(C3S_COMPONENT_DIR, config['database']) ActiveRecord::Base.colorize_logging = false ActiveRecord::Base.logger = Logger.new(File.open(log_file, 'a')) ActiveRecord::Base.establish_connection( :adapter => config['adapter'], :host => config['host'], :username => config['username'], :password => config['password'], :database => db_file, # TODO works only for sqlite3 dbs! :encoding => config['encoding'] ) end |