Skip to content

Instantly share code, notes, and snippets.

@cwsaylor
Forked from bkerley/mongodb.rb
Created November 14, 2009 16:14
Show Gist options
  • Save cwsaylor/234598 to your computer and use it in GitHub Desktop.
Save cwsaylor/234598 to your computer and use it in GitHub Desktop.
db_config = YAML::load(File.read(RAILS_ROOT + "/config/mongodb.yml"))
if db_config[RAILS_ENV] && db_config[RAILS_ENV]['adapter'] == 'mongodb'
mongo = db_config[RAILS_ENV]
connection = Mongo::Connection.new(mongo['host'])
MongoMapper.connection = connection
MongoMapper.database = mongo['database']
if mongo['user'] && mongo['password']
MongoMapper.database.authenticate mongo['user'], mongo['password']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment