Failover with Rails?

Is it possible to change database settings programmatically?

What I am looking for is if there’s a situation where a Find(), or
Create() fails, I would like to be able to redirect Rails to a different
db connection.

I know that this is something that could be accomplished at the OS
level, but because of certain constraints, I need to be able to do this
at the application level.

Thanks in advance.