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
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to