Method: Mongoid::Config#load!

Defined in:
lib/mongoid/config.rb

#load!(path, environment = nil) ⇒ Object

Load the settings from a compliant mongoid.yml file. This can be used for easy setup with frameworks other than Rails.

Examples:

Configure Mongoid.

Mongoid.load!("/path/to/mongoid.yml")

Parameters:

  • path (String)

    The path to the file.

  • environment (String, Symbol) (defaults to: nil)

    The environment to load.

Since:

  • 2.0.1



88
89
90
91
92
93
94
95
96
# File 'lib/mongoid/config.rb', line 88

def load!(path, environment = nil)
  settings = Environment.load_yaml(path, environment)
  if settings.present?
    Sessions.disconnect
    Sessions.clear
    load_configuration(settings)
  end
  settings
end