Connect multiple DB in rails project using AR

Hi,

not sure what and *why* are you trying to do so, but looks like you might want to use some simple metaprogramming to create model classes.

For example: all_servers = Server.find(:all) all_servers.each do |s|    h = {:host => "localhost",         :adapter => "jdbc",         :dialect => "sybase",         :autocommit => false,         :driver => "com.sybase.jdbc3.jdbc.SybDataSource",         :url => "jdbc:sybase:Tds:#{s.host):#{s.port}/LOE_DB",         :username => "username",         :password => "password"}

   eval("class #{Server.name} < ActiveRecord::Base\            end")    eval(Server.name).establish_connection(h)

end

A hack but should work more or less...

Hubert Lepicki wrote:

   eval("class #{Server.name} < ActiveRecord::Base\            end")    eval(Server.name).establish_connection(h)

end

A hack but should work more or less...

Thanks for your help The reason I used this approach is I am building a dashboard application to monitor over 40 data servers. I need to extract a lot of information in those servers and display it through web.

If this approach is not appropriate, could someone suggest alternatives to me?

Million thanks Valentino