You may be able to set up an abstract model with two child models in
which each child uses a different database. One way to connect to
different databases is by using the USE_DB gem. Once your user is
logged in, you can set something in their session then somehow direct
them to one database or the other by changing the value of the use_db
call in the model.
Can I ask why you have two identically structured databases with
different data for login? I’m interested in learning about the use
case.