changing database connnection

I have to change database connection (specifically, the connected user and
password) during a session of a RoR app, depending on user input.

What is the easiest way of doing this?

Horst