Skip to content

Instantly share code, notes, and snippets.

@michelson
Created January 28, 2010 19:16
Show Gist options
  • Save michelson/289041 to your computer and use it in GitHub Desktop.
Save michelson/289041 to your computer and use it in GitHub Desktop.
# environment.rb
config.gem 'mongo_mapper'
#initializers/mongo.rb
begin YAML.load_file("#{RAILS_ROOT}/config/mongo_config.yml")
MONGOCONNECTION = YAML.load_file("#{RAILS_ROOT}/config/mongo_config.yml")[RAILS_ENV]
rescue => e
puts "WARNING! loading config file mongo_config.yml , #{e}"
end
MongoMapper.connection = Mongo::Connection.new(MONGOCONNECTION['ip'])
MongoMapper.database = MONGOCONNECTION['db']
#config/mongo_config.yml
development:
ip: 127.0.0.106
db: mongo_dev
test:
ip: localhost
db: mongo_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment