I have a RoR app that works great with the main RoR database. I also want to connect to arbitrary databases in a way such that I won't recreate the database connection with each new HTTP request. From my research it looks like a connection pool is the way to go.
However, I am having trouble figuring out how to create the pool itself:
config = ActiveRecord::ConnectionAdapters::ConnectionSpecification.new( {
"adapter" => "postgresql",
"host" => "localhost",
"port" => 9000,
"database" => "foo_test",
"username" => "foo",
"password" => "bar",
"pool" => "5",
"timeout" => "3000"
})
my_connection_pool = ActiveRecord::ConnectionAdapters::ConnectionPool.new(config)
This errors with NameError: uninitialized constant ActiveRecord::ConnectionAdapters::ConnectionSpecification. Interstingly ActiveRecord::ConnectionAdapters::ConnectionPool works fine (but doesn't have the right config object).
What do I do here?
And also, are these the right things to be using to solve my problem?