def get_custom_connection(identifier, host, port, dbname, dbuser, password) eval("Custom_#{identifier} = Class::new(ActiveRecord::Base)") eval("Custom_#{identifier}.establish_connection(:adapter=>'mysql', :host=>'#{host}', :port=>#{port}, :database=>'#{dbname}', " + ":username=>'#{dbuser}', :password=>'#{password}')") return eval("Custom_#{identifier}.connection") end