Conectar a mutiples DBs... en Rails 2

Hola que tal.

Si, ya he leido como se conecta a multiples bases de datos. La pregunta
aqui es si existe algun metodo mas simplificado o algun cambio que se
haya hecho en Rails 2.

Para saber si lo hago de la manera “tradicional” (1.2) o la [aun mas]
facil (2) en caso de haberla.


PD: Manera tradicional :

class AbstractApplicationController < ActionController::Base

here, we hop into the front of the request-handling

pipeline to run a method called hijack_db

before_filter :hijack_db

here, we’re going to manually establish a connection

to the database we feel like connecting to.

def hijack_db
# completely ridiculous condition
is_odd = % 2 == 1

# determine the database name
db_name = is_odd ? “dis_odd_db” : “dat_even_db”

# lets manually connect to the proper db
  :adapter  => “mysql”,
  :host     => “localhost”,
  :username => “mr_roboto”,
  :password => “secret_secret_i_got_a_secret”,
  :database => db_name


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