Skip to content

Instantly share code, notes, and snippets.

@cwsaylor
Created May 4, 2010 15:59
Show Gist options
  • Save cwsaylor/389579 to your computer and use it in GitHub Desktop.
Save cwsaylor/389579 to your computer and use it in GitHub Desktop.
# Place in rails config/initializers/
db_config = YAML::load(File.read(RAILS_ROOT + "/config/database.yml"))
if db_config[Rails.env] && db_config[Rails.env]['adapter'] == 'mongodb'
mongo = db_config[Rails.env]
MongoMapper.connection = Mongo::Connection.new(mongo['hostname'])
MongoMapper.database = mongo['database']
end
# Use for database.yml
development:
adapter: mongodb
host: localhost
database: telegram_development
test:
adapter: mongodb
host: localhost
database: telegram_test
production:
adapter: mongodb
host: localhost
database: telegram_production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment