Two databases

Hello all, I’ve got a question. I’m writing a RoR app for a client and
they need me to use two databases, one a mssql database the other a
mysql database. The mssql database will hold the username/password
values. Once I connect to the mssql database, I’ll need to change to
another database to query the information in the reporting software. Any
tips on configuring this?

If all you’re using the MSSQL database for is a username and password,
you ought to make the MySQL database the primary database. In
database.yml, add configuration for your MSSQL server. It will look
something like:

mssql_connection:
adapter: sqlserver
database: dbmydatabase
host: sqlserver.domain.com
username: user
password: secret

Then, generate a model in your project and insert code akin to:

class LoginInfo < ActiveRecord::Base
set_table_name “user_info”
establish_connection :mssql_connection

def fetch_username
# code to get username here
end

def fetch_password
# code to get password here
end
end

Then you should be able to call UserInfo.fetch_username from within
your app and the username will be returned.

On Aug 27, 11:24 am, Joshua T. [email protected]

Joshua T. wrote:

Hello all, I’ve got a question. I’m writing a RoR app for a client and
they need me to use two databases, one a mssql database the other a
mysql database. The mssql database will hold the username/password
values. Once I connect to the mssql database, I’ll need to change to
another database to query the information in the reporting software. Any
tips on configuring this?

If the only thing you are using the SQL Server for is authentication,
wrap it with a quick web service and just use that instead of a rails
model.