I am still having fun with multiple databases. In this case it is the
unless connected? statement.
ActiveRecord::Base establishes a connection that is inherited by the
majority of my models. However one Model (Componentlog) that uses a
separate DB is coded as:
:adapter => “oci”,
:database => “”,
:host => “oracle7”,
:username => “vcgeneral”,
:password => “manhattan”
I use unless connected? to stop it using a new connection every time the
model is acccessed.
This works fine as long as that model is the first accessed by the
application. Because ActiveRecord::Base hasn’t established it’s
connection yet (From the looks of it) this Model happily establishes its
If, however, ActiveRecord::Base HAS established a connection this class
will use that (incorrect) one because I assume it inherits from
ActiveRecord::Base and the connected? method checks all superclasses
What I need to say essentially is that When it comes to the connection
this class doesn’t inherit the connections.
Does anyone know a way to do this?
I have tried having an intermediate class that this one inherits from
where the establish connection is over-ridden but if connected? doesn’t
see a connection there is still tracks up to ActiveRecord::Base instead
of saying “Ok, it isn’t in this class, I’ll establish a new connection”
This is all what I think is happening. I am a beginner so if I am
missing something obvious I do apologise
Now that I think about it. I will try removing the unless connected? bit
because I am now running mongrel with allow_concurrency off in