Module: Rails::Mongoid
Overview
:nodoc:
Defined Under Namespace
Classes: Railtie
Instance Method Summary collapse
-
#create_indexes(pattern) ⇒ Array<String>
Create indexes for each model given the provided pattern and the class is not embedded.
-
#load_models(app) ⇒ Object
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.
Instance Method Details
#create_indexes(pattern) ⇒ Array<String>
Create indexes for each model given the provided pattern and the class is not embedded.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails/mongoid.rb', line 17 def create_indexes(pattern) Dir.glob(pattern).each do |file| begin model = determine_model(file) if model model.create_indexes Logger.new($stdout).info("Generated indexes for #{model}") end rescue => e end end end |
#load_models(app) ⇒ Object
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.
38 39 40 41 42 43 44 45 |
# File 'lib/rails/mongoid.rb', line 38 def load_models(app) return unless ::Mongoid.preload_models app.config.paths["app/models"].each do |path| Dir.glob("#{path}/**/*.rb").sort.each do |file| load_model(file.gsub("#{path}/" , "").gsub(".rb", "")) end end end |