Hello! I've looked through the mailing list archives, but havn't found a viable answer for this question. I would like to have my rails app handle a couple tables in a legacy database. Looking at the wiki, comments in the rails code, and searching for past comments on this list, I've tried two different methods that are both broken. At least for PostgreSQL, I havn't testing this bug with any other databases. First method is establishing the connection in environment.rb like such: MyModel.establish_connection :my_db This only works the first time if the page loaded uses MyModel. All subsequent calls defaults to the connection for ActiveRecord::Base. I can see the entry in active_connections, but it doesn't seem to be used. Second option is putting the extablish_connection directly in the my_model.rb file. class MyModel < ActiveRecord::Base establish_connection :my_db end This works.. until you start having your db complain about too many connections. It will open a new database connection each time you access the model, and it leaves all previous connections open. Taking a look at active_connections will show multiple entries for MyModel. Does anyone have a solution that will work, and won't make multiple connections that will never be used again? Thanks for any help, Ken...
on 2005-11-30 22:55
on 2005-11-30 23:03
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 30, 2005, at 1:51 PM, Ken Bowley wrote: > > MyModel.establish_connection :my_db > > This only works the first time if the page loaded uses MyModel. > All subsequent calls defaults to the connection for > ActiveRecord::Base. I can see the entry in active_connections, but > it doesn't seem to be used. This was fixed in http://dev.rubyonrails.org/ticket/2996 jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDjiEEAQHALep9HFYRAjEAAKC6NAp2UfRXMsdTj3u/Af3hEUvc8QCfXEls YUeLL3a4HPezp0ayAPBSHh4= =Ti8R -----END PGP SIGNATURE-----
on 2005-11-30 23:40
On Wed, 30 Nov 2005, Jeremy Kemper wrote: > This was fixed in http://dev.rubyonrails.org/ticket/2996 > > jeremy Thank you! I've filed a bug report with Debian in the hopes that the fix will make it into the official Debian packages soon.