Hi,

currently in my project I've implemented support in AR to create different 
connection pools and switch between them depending on user's input.

Currently rails give you an option to override connection per model, but 
there is no way to change this connection dynamically based on user locale, 
or subdomain, or anything else.
Also there is no easy way to change connection for a whole app (especially 
when using threaded servers like puma)

I'm curios is there any need for such functionality or this is only my edge 
case? Quick search shows that there was some interest in this 
<https://www.google.com/search?q=rails+multiple+database+dynamic&safe=off>

My draft API proposition is:

Add any number of DB's to config/database.yml with underscores:

development:
...

development_alternative:
...

development_another_alternative:
...

and just in your app code set currently needed connection

ActiveRecord::Base.current_active_connection = :alternative

Behind the scenes AR will create separate connection pool for an each 
namespace and will use specified.

What do you think? I will create a PR if anyone need this besides me

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to