Sha256: 4a2cfc3a38f1a322568e736e3e4f7678c2ccacf991b6d761c83579240593a0d4

Contents?: true

Size: 567 Bytes

Versions: 35

Compression:

Stored size: 567 Bytes

Contents

# frozen_string_literal: true
require 'active_record'
require 'erb'

module DatabaseConnection
  def self.connect!(env)
    # Ref https://github.com/puma/puma#clustered-mode
    ActiveSupport.on_load(:active_record) do
      ::ActiveRecord::Base.connection_pool.disconnect! if ::ActiveRecord::Base.connected?
      ::ActiveRecord::Base.configurations = YAML.safe_load(ERB.new(File.read("db/config.yml")).result, [], [], true) || {}
      config = ::ActiveRecord::Base.configurations[env.to_s]
      ::ActiveRecord::Base.establish_connection(config)
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
valkyrie-3.0.0.pre.beta.1 lib/config/database_connection.rb
valkyrie-2.2.0 lib/config/database_connection.rb
valkyrie-2.1.2 lib/config/database_connection.rb
valkyrie-2.1.1 lib/config/database_connection.rb
valkyrie-2.1.0 lib/config/database_connection.rb
valkyrie-2.0.2 lib/config/database_connection.rb
valkyrie-2.0.1 lib/config/database_connection.rb
valkyrie-2.0.0 lib/config/database_connection.rb
valkyrie-2.0.0.RC10 lib/config/database_connection.rb
valkyrie-2.0.0.RC9 lib/config/database_connection.rb
valkyrie-1.7.1 lib/config/database_connection.rb
valkyrie-2.0.0.RC8 lib/config/database_connection.rb
valkyrie-1.7.0 lib/config/database_connection.rb
valkyrie-2.0.0.RC7 lib/config/database_connection.rb
valkyrie-2.0.0.RC6 lib/config/database_connection.rb
valkyrie-2.0.0.RC5 lib/config/database_connection.rb
valkyrie-2.0.0.RC4 lib/config/database_connection.rb
valkyrie-1.6.0 lib/config/database_connection.rb
valkyrie-1.5.1 lib/config/database_connection.rb
valkyrie-2.0.0.RC3 lib/config/database_connection.rb