Skip to content

Instantly share code, notes, and snippets.

@bkerley
Created November 14, 2009 15:59
Show Gist options
  • Save bkerley/234595 to your computer and use it in GitHub Desktop.
Save bkerley/234595 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