Skip to content

Instantly share code, notes, and snippets.

@g3d
Created February 13, 2013 15:04
Show Gist options
  • Save g3d/4945221 to your computer and use it in GitHub Desktop.
Save g3d/4945221 to your computer and use it in GitHub Desktop.
Some Espresso improvement
require File.expand_path('../base/boot', __FILE__)
if Cfg.db[:type] && Cfg.db[:name]
values = Cfg.db.values_at(:type, :user, :pass, :host, :name)
if Cfg.db[:type] == 'sqlite'
values = [values.first, Cfg.root_path(values.last)]
connection_string = '%s://%s' % values
else
values = Cfg.db.values_at(:type, :user, :pass, :host, :name)
connection_string = '%s://%s:%s@%s/%s' % values
end
DataMapper.setup :default, connection_string
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment