Module: SinatraHelpers::ActiveRecord

Defined in:
lib/sinatra_helpers/active_record.rb

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/sinatra_helpers/active_record.rb', line 9

def registered(app)
  db_config_file = File.join(Sinatra::Application.root,'config',"database.yml")
  db_config = YAML.load(ERB.new(IO.read(db_config_file)).result)
  db = (db_config[Sinatra::Application.environment.to_s]).symbolize_keys
  ::ActiveRecord::Base.establish_connection(db)
  ::ActiveRecord::Base.logger = Logger.new(STDOUT)
end