OK, you can find some howto’s everywhere on the web but only on this site I found the complete solution:

[sourcecode language='ruby']
class SecondConnection < ActiveRecord::Base

SecondConnection.establish_connection(
:adapter => “informix”,
:host => “localhost”,
:username => “hansnase”,
:password => “very_secret”,
:database => “ccdb@localhost”
)

self.abstract_class = true
end
[/sourcecode]

“self.abstract_class = true” makes the thing actually work. Otherwise Rails seems to cache the database connection and does not switch back if you access any other classes but SecondConnection.

Yeah!

Later: Not so Yeah…

I had to establish another call to
[sourcecode language='ruby']
ActiveRecord::Base.establish_connection
logger.info { “Establishing Base Connection” }
log_connections
[/sourcecode]

I assume it’s either an Informix problem or related to the old rails version I’m driving with.
Nevertheless: It works now.

Tagged with:  

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>