Last Updated: February 25, 2016
·
2.214K
· kevinthompson

Mongoid Configuration for MongoHQ Replica Sets

Although Heroku's documentation states that hosts may need to be defined when working with MongoDB replica sets, the format of this configuration is a bit more difficult to track down.

On MongoHQ, that configuration looks something like this for a production environment:

# Production
production:
  hosts:
    - - subdomain.member0.mongohq.com
      - 10028
    - - subdomain.member1.mongohq.com
      - 10028
  database: database-name
  username: <%= ENV['DB_USER'] %>
  password: <%= ENV['DB_PASS'] %>
  allow_dynamic_fields: false
  raise_not_found_error: false
  logger: false
  persist_in_safe_mode: true
  max_retries_on_connection_failure: 15
  read_secondary: true

Your host domains and ports will vary, but the rest of this configuration is fairly standard.