Guest User

Untitled

a guest
Jul 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. config_file = Rails.root.join('config/mongo.yml')
  2.  
  3. if config_file.file?
  4. config = YAML.load(ERB.new(config_file.read).result)[Rails.env]
  5.  
  6. MongoMapper.connection = Mongo::Connection.new(config['host'], config['port'], :logger => Rails.logger)
  7. if config['username']
  8. conn.authenticate(config['username'], config['password']) || raise("Invalid MongoDB Authentication")
  9. end
  10. MongoMapper.database = config['database']
  11. end
Add Comment
Please, Sign In to add comment