Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5439

Generators: Generate `config/initializers/mongoid.rb`

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 9.0.0
    • Affects Version/s: None
    • Component/s: None

      Currently, Mongoid has a generator which generates `config/mongoid.yml` for new apps.

      In addition, for Rails apps, we should generate `config/initializers/mongoid.rb`. This important after releasing MONGOID-5293 (config.load_defaults option), to ensure all newly generated apps are properly locking their Mongoid version.

      The generated initializer should look like:

      # config/initializers/mongoid.rb
      
      Mongoid.configure do
      
        # Load Mongoid behavior defaults. This automatically sets
        # features flags (refer to documentation)
        config.load_defaults[<%= Mongoid::VERSION %>]
      end
      
      # Enable Mongo driver query cache for Rack
      # Rails.application.config.middleware.use(Mongo::QueryCache::Middleware)
      
      # Enable Mongo driver query cache for ActiveJob
      # ActiveSupport.on_load(:active_job) do
      #   include Mongo::QueryCache::Middleware::ActiveJob
      # end

      I've included the latter two Query cache items because users should be aware of these. They should probably be commented out by default.

       

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: