Sha256: 4bd22c79f8e633f0c63e9316b5dfa125bfe39458014c30ba4ce604aa8622ec38

Contents?: true

Size: 638 Bytes

Versions: 9

Compression:

Stored size: 638 Bytes

Contents

Appfuel::Initialize.define('global.db') do |config, container|
  fail "[initializer db] :db config not found" unless config.key?(:db)
  fail "[initializer db] :main not found in :db" unless config[:db].key?(:main)

  require 'pg'
  require 'active_record'
  config[:db][:main] = config[:db][:main].with_indifferent_access

  ActiveSupport.on_load(:active_record) do
    if ActiveRecord::Base.connected?
      ActiveRecord::Base.connection_pool.disconnect!
    end

    if container.key?(:logger)
      ActiveRecord::Base.logger = container[:logger]
    end

    ActiveRecord::Base.establish_connection(config[:db][:main])
  end
  nil
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
appfuel-0.4.5 lib/appfuel/initializers/db.rb
appfuel-0.4.4 lib/appfuel/initializers/db.rb
appfuel-0.4.3 lib/appfuel/initializers/db.rb
appfuel-0.4.2 lib/appfuel/initializers/db.rb
appfuel-0.4.1 lib/appfuel/initializers/db.rb
appfuel-0.4.0 lib/appfuel/initializers/db.rb
appfuel-service-0.1.7 lib/appfuel/service/initializers/db.rb
appfuel-service-0.1.6 lib/appfuel/service/initializers/db.rb
appfuel-service-0.1.4 lib/appfuel/service/initializers/db.rb