Method: Mongoid::Loadable#load_models

Defined in:
lib/mongoid/loadable.rb

#load_models(paths = model_paths) ⇒ Object

Search a list of model paths to get every model and require it, so that indexing and inheritance work in both development and production with the same results.

Examples:

Load all the application models from default model paths.

Mongoid.load_models

Load all application models from a non-standard set of paths.

Mongoid.load_models(%w( ./models ./admin/models ))

Parameters:

  • paths (Array) (defaults to: model_paths)

    The list of paths that should be looked in for model files. These must either be absolute paths, or relative to the current working directory.



33
34
35
36
37
38
39
40
41
# File 'lib/mongoid/loadable.rb', line 33

def load_models(paths = model_paths)
  files = files_under_paths(paths)

  files.sort.each do |file|
    load_model(file)
  end

  nil
end