Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quickly get it to work
config1 = { :database => "db1", :host => "localhost", :port => 15432 }
spec1 = ActiveRecord::Base::ConnectionSpecification.new(config1, "postgresql_connection")
handler1 = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
handler1.establish_connection("db1", spec1)
handler1.connection_pools.values.first.with_connection { ... }
config2 = { :database => "db2", :host => "localhost", :port => 15432 }
spec2 = ActiveRecord::Base::ConnectionSpecification.new(config2, "postgresql_connection")
handler2 = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
handler2.establish_connection("db2", spec2)
handler2.connection_pools.values.first.with_connection { ... }
# rails runner multiple_connection_pools.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.