Skip to content

Instantly share code, notes, and snippets.

@benwyrosdick
Forked from adamwiggins/mongo_connect.rb
Created February 24, 2010 07:59
Show Gist options
  • Save benwyrosdick/313234 to your computer and use it in GitHub Desktop.
Save benwyrosdick/313234 to your computer and use it in GitHub Desktop.
config = URI.parse(ENV['MONGO_URL'] || 'mongodb://localhost:27017/thedb')
MongoMapper.connection = Mongo::Connection.new(config.host, config.port)
MongoMapper.database = config.path.gsub(/^\//, '')
MongoMapper.database.authenticate(config.user, config.password) if config.user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment