Skip to content

Instantly share code, notes, and snippets.

@esedor
Created November 8, 2011 18:38
Show Gist options
  • Save esedor/1348665 to your computer and use it in GitHub Desktop.
Save esedor/1348665 to your computer and use it in GitHub Desktop.
New MongoDB Connection in Ruby
require 'mongo'
mongo_uri = 'mongodb://user:pass@localhost:27017/dbname'
db_name = 'dbname'
connection = Mongo::Connection.from_uri(mongo_uri)
db = connection.db(db_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment