We’re using two databases, one main, and one secondary in a seperate model, like so:
class SecondModel < ActiveRecord::Base
establish_connection(ENV['SECOND_DATABASE'])
end
I’m going to switch to Unicorn on a Heroku app, and we have to disconnect the database here:
before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
end
I am not sure about closing the connection for the second database.
Does anybody have any thoughts on this?
Ok I think I got it working now, here is the code:
I’ve got some errors because I was verifying the connections before re-connection to the SecondModel’s database.
Any thoughts are welcome!