Use Bundler.require
Close the database connection at the end of the thread