Sha256: a966631ee986d1d846bc011e9ff94842104a66df2af61723978fb1e944a868ef

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

require "active_record"

module Jets::Internal
  # Reference: https://github.com/rails/rails/blob/master/actionmailer/lib/action_mailer/railtie.rb
  class Activerecord < ::Jets::Turbine
    config.active_record = ActiveSupport::OrderedOptions.new
    config.active_record.log_queries = false

    rake_tasks do
      namespace :db do
        task :load_config do
          if defined?(ENGINE_ROOT) && engine = Jets::Engine.find(ENGINE_ROOT)
            if engine.paths["db/migrate"].existent
              ActiveRecord::Tasks::DatabaseTasks.migrations_paths += engine.paths["db/migrate"].to_a
            end
          end
        end
      end

      load "active_record/railties/databases.rake"
    end

    initializer "active_record.initialize_database" do
      ActiveSupport.on_load(:active_record) do
        self.configurations = Jets.application.config.database_configuration
        establish_connection
      end
    end

    initializer "active_record.logger" do
      # use STDOUT instead of Jets.logger so we don't have to set Jets.logger.level = :debug
      if config.active_record.log_queries || ENV['JETS_AR_LOG'] || ENV['AR_LOG']
        ActiveSupport.on_load(:active_record) { self.logger = Logger.new(STDOUT) }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 engines/internal/lib/internal/activerecord.rb
jets-5.0.12 engines/internal/lib/internal/activerecord.rb
jets-5.0.11 engines/internal/lib/internal/activerecord.rb
jets-5.0.10 engines/internal/lib/internal/activerecord.rb
jets-5.0.9 engines/internal/lib/internal/activerecord.rb
jets-5.0.8 engines/internal/lib/internal/activerecord.rb
jets-5.0.7 engines/internal/lib/internal/activerecord.rb
jets-5.0.6 engines/internal/lib/internal/activerecord.rb
jets-5.0.5 engines/internal/lib/internal/activerecord.rb
jets-5.0.4 engines/internal/lib/internal/activerecord.rb
jets-5.0.3 engines/internal/lib/internal/activerecord.rb
jets-5.0.2 engines/internal/lib/internal/activerecord.rb
jets-5.0.1 engines/internal/lib/internal/activerecord.rb
jets-5.0.0 engines/internal/lib/internal/activerecord.rb
jets-5.0.0.beta1 engines/internal/lib/internal/activerecord.rb