I have two databases I need to work with, one oracle on a remote box, and one mysql on my local box. The oracle DB only has SOME of the data I need to work with, so I set up my models to use the mysql database by default, and the few models I needed to work with oracle, I did:
establish_connection "oracle_database"
Which worked just fine.
Unfortunately, I’ve just been informed that I can’t rely on the remote oracle database being available. My new requirement is that my system needs to be able to use the oracle database (if available), or, if it isn’t, needs to use a local database that would have the same sorts of tables/columns/etc.
This seems like something Rails wouldn’t actually be built to support? Am I going to be stuck manually editing my database.yml file to change “oracle_database” to sometimes point at the remote DB, and sometimes point at the local one?
You could use begin rescue to catch an exception while establishing connection to remote server, like this