Sha256: e0546a476c612321d046008dd08acb8e58ebb44e8f923a936f36ebcd1f0f9b3f

Contents?: true

Size: 499 Bytes

Versions: 5

Compression:

Stored size: 499 Bytes

Contents

# This is a hack that forces AR to share its connection between different
# threads. Useful for Capybara when you are not using rack-test.
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
hermes-0.6.0 lib/hermes/perf/shared_connection.rb
hermes-0.5.1 lib/hermes/perf/shared_connection.rb
hermes-0.5.0 lib/hermes/perf/shared_connection.rb
hermes-0.4.1 lib/hermes/perf/shared_connection.rb
hermes-0.4.0 lib/hermes/perf/shared_connection.rb