Skip to content

Instantly share code, notes, and snippets.

@brookemckim
Created June 6, 2011 00:38
Show Gist options
  • Save brookemckim/1009592 to your computer and use it in GitHub Desktop.
Save brookemckim/1009592 to your computer and use it in GitHub Desktop.
MongoDB Initializer
require 'yaml'
config = YAML.load_file(File.expand_path(File.join(SINATRA_ROOT, 'config', 'mongo.yaml')))
db = config[ENV['RACK_ENV'].downcase]
uri = "mongodb://#{db['username']}:#{db['password']}@#{db['host']}:#{db['port']}/#{db['database']}"
DB = Mongo::Connection.from_uri(uri).db(db['database'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment