In response to Wukerplank, you can also put connection data in database.yml, as usual, with this name:
log_database_production: adapter: mysql host: other_host username: logmein password: supersecret database: logs
Then in your special model:
class AccessLog < ActiveRecord::Base establish_connection "log_database_
So that these annoying credentials are in your application code.
Edit: If you want to reuse this connection in several models, you must create a new abstract class and inherit it, because the connections are closely related to the classes (as explained here , here , and here ), and new connections will be created for each class.
If so, set things up like this:
class LogDatabase < ActiveRecord::Base self.abstract_class = true establish_connection "log_database_#{Rails.env}".to_sym end class AccessLog < LogDatabase end class CheckoutLog < LogDatabase end
Unixmonkey May 25 '11 at 15:11 2011-05-25 15:11
source share