Magic multi connections with association problem


#1

Dear all

I am using magic multi connections, there is some problem when using
association. How can I dynamic determine the module name (i.e.
A::Request, B::Request) in activerecord association.

Below is my code:

module A
establish_connection :A
end

module B
establish_connection :B
end

and many module…

class Request < ActiveRecord::Base
set_table_name “request”
set_primary_key “req_reqno”
has_many :testrslt, :class_name => “Testrslt”, :foreign_key =>
“testrslt_reqno”
end

class Testrslt < ActiveRecord::Base
set_table_name “testrslt”
belongs_to :request, :class_name => “Request”, :foreign_key =>
“testrslt_reqno”
end

a = DBA::Request.last
=> It is ok

a.testrslt
=> # The association is not referring to A connection…

I want the :class_name as below if A connection is used…

class Request < ActiveRecord::Base
set_table_name “request”
set_primary_key “req_reqno”
has_many :testrslt, :class_name => “A::Testrslt”, :foreign_key =>
“testrslt_reqno”
end

class Testrslt < ActiveRecord::Base
set_table_name “testrslt”
belongs_to :request, :class_name => “A::Request”, :foreign_key =>
“testrslt_reqno”
end

Part of my gem list
magic_multi_connections (1.2.1)
rails (2.2.2)

Please advise.

Many thanks
Valentino