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
class Bar < ActiveRecord::Base
class Baz < ActiveRecord::Base
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.