In my app, for three models: foo,bar and baz, the database connection is made to a different database and hence in model code: class Foo < ActiveRecord::Base establish_connection :diff_database end class Bar < ActiveRecord::Base establish_connection :diff_database end class Baz < ActiveRecord::Base establish_connection :diff_database end Now, the problem is, if is use the above code, not one but three connections to another database is made and it seems that number of connections made to the database keeps rising. The mysql forks a new process for handling each new connection and following shell command reports a rising number of forked processes. ps ax|grep mysql|egrep ''local''|wc -l And eventually when number of forked processes touches > 35, then i get error, Mysql::Error too many connections open. Now, I must use these three tables from old database because of some datab constraints, so what are my options here? Any pointers would be appreciated. -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
class LegacyDB < ActiveRecord::Base self.abstract_class = true # this prevents ActiveRecord from trying to find a table called "legacy_d_b" or the like establish_connection :diff_database end class Foo < LegacyDB end class Bar < LegacyDB end class Baz < LegacyDB end hemant wrote:> In my app, for three models: foo,bar and baz, the database connection > is made to a different database and hence in model code: > > class Foo < ActiveRecord::Base > establish_connection :diff_database > end > > class Bar < ActiveRecord::Base > establish_connection :diff_database > end > > class Baz < ActiveRecord::Base > establish_connection :diff_database > end > > Now, the problem is, if is use the above code, not one but three > connections to another database is made and it seems that number of > connections made to the database keeps rising. > > > The mysql forks a new process for handling each new connection and > following shell command reports a rising number of forked processes. > > ps ax|grep mysql|egrep ''local''|wc -l > > And eventually when number of forked processes touches > 35, then i > get error, Mysql::Error too many connections open. > > Now, I must use these three tables from old database because of some > datab constraints, so what are my options here? > > Any pointers would be appreciated. > >-- Lance Ivy Web Applications Developer RBS Interactive lance.ivy-eTT0+Q0rEURLdZBKzJmsdNBPR1lH4CV8@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/13/06, Lance Ivy <lance.ivy-eTT0+Q0rEURLdZBKzJmsdNBPR1lH4CV8@public.gmane.org> wrote:> > class LegacyDB < ActiveRecord::Base > self.abstract_class = true # this prevents ActiveRecord from trying > to find a table called "legacy_d_b" or the like > establish_connection :diff_database > end >Thanks man. -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---