For multiple database connections, is it better to have a mixin included into the model that does a establish connection on included event or is it better to have an abstract class that establishes the connnection and inherit from the abstract class? In particular, how do Rails handle database connections? It is supposed to use a connection pool, does the pooling break if you use a mixin? Mixin: module CustomConnect def self.included(base) config = ActiveRecord::Base.configurations["custom_"+RAILS_ENV] base.establish_connection(config) end end and then you do a class abc < ActiveRecord::Base include CustomConnect end Inheritance: class CustomConnect < ActiveRecord::Base self.abstract_class = true config = ActiveRecord::Base.configurations["custom_"+RAILS_ENV] establish_connection(config) end class abc < CustomConnect end When you have a significant number of models, how are database connections handled and which approach is better?
on 2008-12-05 06:36
on 2008-12-07 04:51
Does anyone have an input on connection pooling and which approach is better?