Skip to content

Instantly share code, notes, and snippets.

@oma
Forked from tal/mongoid.yml
Created June 9, 2012 12:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oma/2900804 to your computer and use it in GitHub Desktop.
Save oma/2900804 to your computer and use it in GitHub Desktop.
development: &defaults
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default: &default_session
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: delight_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Change whether the session persists in safe mode by default.
# (default: false)
# safe: false
# Change the default consistency model to :eventual or :strong.
# :eventual will send reads to secondaries, :strong sends everything
# to master. (default: :eventual)
# consistency: :strong
# Configure Mongoid specific options. (optional)
options:
# Configuration for whether or not to allow access to fields that do
# not have a field definition on the model. (default: true)
# allow_dynamic_fields: true
# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false
# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false
# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false
# Preload all models in development, needed when models use
# inheritance. (default: false)
preload_models: true
# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true
# Raise an error when performing a #find and the document is not found.
# (default: true)
raise_not_found_error: false
# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false
# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false
# User Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true
# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
<<: *defaults
sessions:
default:
<<: *default_session
database: delight_test
<% if ENV['MONGOHQ_URL'] %>
<% uri = URI.parse(ENV['MONGOHQ_URL']) %>
production:
<<: *defaults
sessions:
default:
<<: *default_session
database: <%= uri.path.sub('/','') %>
username: <%= uri.user %>
password: <%= uri.password %>
hosts:
- <%= uri.host %>:<%= uri.port %>
<% end %>
@oma
Copy link
Author

oma commented Jun 9, 2012

edited to handle the case for dev and test when ENV var MONGOHQ_URL is not present.

@christianhager
Copy link

thank you both :)

@assembler
Copy link

In newest version of mongoid, you can just use this:

production:
  sessions:
    default:
      uri: <%= ENV['MONGO_URI'] %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment