I'm trying to understand the best way to get the connection to my databases.
At the moment I've got a method which parses the URL (depending on the URL called the application has to connect to a different database, like customer1.example.com will connect to the customer1 database) and calls
ActiveRecord::Base.establish_connection(conn_string)
where conn_string contains the name of the database.
This method (set_db) is called with a
before_filter :set_db
in my Application controller, so basically for each request I get, the URL is parsed and the application try to do an establish_connection.
I was wondering if I can have a connection pool somewhere....do you have any suggestion about that? Is it better to have a Singleton which keep all the connections made and gives back the right one?
Thanks! Roberto