Does anyone have an input on connection pooling and which approach is
better?
On Dec 5, 10:35 am, Mukund
<marut...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> 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?
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---