Centralizing DB connection code

Hello masters,
I have a standalone ruby program that has many code files in many
directories.The program interacts with the DB so a lot of the code files
have:

ActiveRecord::Base.establish_connection(
  :adapter => "mysql",
  :database => "b2b",
  :username => "root",
  :password => "Mu2008",
  :socket => "/var/lib/mysql/mysql.sock",
  :host => "207.28.2.108"
)

Is there a way to centralize this code and create a global connection
object?
So I initialize it once and use it everywhere.

Regards,
Raj

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs