Forum: Radiant CMS Can extensions use a different database?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
31e7188882f9871237de49de80384c07?d=identicon&s=25 Colin Nederkoorn (Guest)
on 2007-03-27 21:03
(Received via mailing list)
We're almost done with our radiant site, but have a few remaining
things. I asked a question previously about embedding another RoR app
in Radiant. The solution I have right now is to use an iFrame. What's
not good about this is you define the size for the iFrame and the
screen real-estate used is not dynamically updated - not to mention
maintaining another ruby on rails app!

My requirements for this app are pretty basic and I should be able to
port it to an extension:
- take one text box of input (autofilled based on an external database*)
- Query the external database* based on the chosen input
- Pass part of the result to a c++ console app
- Parse the output from the c++ app and display in a table.

Where I am uncertain is - Can you query a different database from an
extension? If so, how?


P.S. Since a pic is worth 1000 words... here is a mockup of what I am
trying to do. The side and the top menus are rendered in radiant. The
input field and result are what my extension needs to handle. My
extension needs two pages - an index and a view. The mockup is of the
8802b1fa1b53e2197beea9454244f847?d=identicon&s=25 Sean Cribbs (Guest)
on 2007-03-27 21:12
(Received via mailing list)
This is a pretty common question with ActiveRecord in general.
Essentially, yes you can.

Inside your model, I believe you use the "establish_connection" call.
That will connect to the specified database in only that model.


p.s. see
767bedcbd5dd54d874a602925d98182e?d=identicon&s=25 Oliver Baltzer (Guest)
on 2007-03-27 21:13
(Received via mailing list)
Hi Colin:

Colin Nederkoorn wrote:
> Where I am uncertain is - Can you query a different database from an
> extension? If so, how?

I don't think Rails currently has support for connecting to two
databases simultaneously. However, if you are familiar with SQL you can
always setup a second database connection in your extension and then
"manually" query the second database with a database interface other
than ActiveRecord, e.g. DBI. Of course you won't have the luxurious
ActiveRecord wrappers, but you may even be able to bend those to work
with a second connection.

This topic is locked and can not be replied to.