Permalink
Browse files

Fix default connection.

  • Loading branch information...
1 parent 5b24a72 commit 4ac4e2acbc7cf2060161a4ca17ae083da141cfd1 Alexander Staubo committed May 18, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/multidb/balancer.rb
View
@@ -20,6 +20,7 @@ def connection
class Balancer
def initialize(configuration)
+ @default_candidate = Candidate.new(@configuration.default_adapter)
@candidates = {}.with_indifferent_access
@configuration = configuration
@configuration.raw_configuration[:databases].each_pair do |name, config|
@@ -31,7 +32,7 @@ def initialize(configuration)
end
end
unless @candidates.include?(:default)
- @candidates[:default] = [Candidate.new(@configuration.default_adapter)]
+ @candidates[:default] = [@default_candidate]
end
end
@@ -64,7 +65,7 @@ def use(name, &block)
end
def current_connection
- Thread.current[:multidb_connection] ||= ActiveRecord::Base.connection_pool.connection
+ Thread.current[:multidb_connection] ||= @default_candidate.connection
end
class << self

0 comments on commit 4ac4e2a

Please sign in to comment.