Sha256: 9c012fbba3538fac1be949d8508f4c1dc1ace0f59fa09e23eaf45b4b2810ed2d

Contents?: true

Size: 386 Bytes

Versions: 5

Compression:

Stored size: 386 Bytes

Contents

require 'active_record'

class ActiveRecord::Base
  mattr_accessor :shared_connection
  @@shared_connection = nil

  def self.connection
    @@shared_connection || retrieve_connection
  end
end

# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kookaburra-0.18.3 lib/kookaburra/utils/active_record_shared_connection.rb
kookaburra-0.18.2 lib/kookaburra/utils/active_record_shared_connection.rb
kookaburra-0.18.1 lib/kookaburra/utils/active_record_shared_connection.rb
kookaburra-0.18.0 lib/kookaburra/utils/active_record_shared_connection.rb
kookaburra-0.17.1 lib/kookaburra/utils/active_record_shared_connection.rb