def load_models(app)
      app.config.paths["app/models"].expanded.each do |path|
        preload = ::Mongoid.preload_models
        if preload.resizable?
          files = preload.map { |model| "#{path}/#{model.underscore}.rb" }
        else
          files = Dir.glob("#{path}/**/*.rb")
        end

        files.sort.each do |file|
          load_model(file.gsub("#{path}/" , "").gsub(".rb", ""))
        end
      end
    end
def load_models(app)
      app.config.paths["app/models"].expanded.each do |path|
        preload = ::Mongoid.preload_models
        if preload.resizable?
          files = preload.map { |model| "#{path}/#{model.underscore}.rb" }
        else
          files = Dir.glob("#{path}/**/*.rb")
        end

        files.sort.each do |file|
          load_model(file.gsub("#{path}/" , "").gsub(".rb", ""))
        end
      end
    end
Use the application configuration to get every model and require it, so
 that indexing and inheritance work in both development and production
 with the same results.

 @example Load all the application models.
   Rails::Mongoid.load_models(app)

 @param [ Application ] app The rails application.