Connect to two databases / Delegate authentication?

Hello,

I need to write a Rails application with user authentication.

This is no problem so far, but the company that needs the rails
application does have a large user database that is used for an already
existing application.

In the new Rails application, there are four types of users with
different rights. The existing users should be equal to one of these
types.

When authenticating, the Rails application should first try to find the
user in the own database. If this step fails, it should try to
authenticate the user against the Oracle Database.

So is it possible to connect to a MySQL database for data storage and
additionally connect to an Oracle DB for user authentication? Even if
the database scheme in the Oracle DB is fixed, does not comply with
ActiveRecord standards and can’t be changed?

Any help on this topic is appreciated.

Code Xy wrote:

Hello,

I need to write a Rails application with user authentication.

This is no problem so far, but the company that needs the rails
application does have a large user database that is used for an already
existing application.

In the new Rails application, there are four types of users with
different rights. The existing users should be equal to one of these
types.

When authenticating, the Rails application should first try to find the
user in the own database. If this step fails, it should try to
authenticate the user against the Oracle Database.

So is it possible to connect to a MySQL database for data storage and
additionally connect to an Oracle DB for user authentication? Even if
the database scheme in the Oracle DB is fixed, does not comply with
ActiveRecord standards and can’t be changed?

Any help on this topic is appreciated.

You can create another model that uses
ActiveRecord::Base.establish_connection (see api) to connect to your
OracleDB, and then query that model if search in the Rails app DB fails.
See also here:

http://wiki.rubyonrails.com/rails/pages/HowtoUseMultipleDatabases

Thanks, I did not know they cover this in the wiki!

François Montel wrote:

You can create another model that uses
ActiveRecord::Base.establish_connection (see api) to connect to your
OracleDB, and then query that model if search in the Rails app DB fails.
See also here:

Peak Obsession