Hi,

I've never done what you are trying but my understanding is that every
time that your code executes it opens a new connection to the
database. I just looked at establish_connection's code and it doesn't
seem to check if there is an existing connection matching the
parameters passed. I could be wrong, though. I am not a Rails expert.

Since you are going to be trying to create the connection from a Ruby
program your program will be able to replace your variables with
values so my guess is that yes, you can do it. Have you tried?

Pepe

On Apr 30, 4:41 pm, elioncho <[email protected]> wrote:
> Can I make it load in every request?
>
> On Apr 30, 1:33 pm, elioncho <[email protected]> wrote:
>
> > Hello guys,
>
> > I'm using the establish connection method on my models to connect to
> > different databases. My question is : Is it possible to connect to
> > various databases dynamically as I'm trying to do (I am sending a name
> > param) or does the connection params are only loaded once and can't be
> > changed?
>
> > ActiveRecord::Base.establish_connection(
> >       :adapter => "sqlite",
> >       :database  => "db_#{name}"
> >     )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to