Commit 521a7caf authored by Lin Jen-Shin's avatar Lin Jen-Shin

Try this way to provide database connection

parent 887aeefb
......@@ -31,13 +31,10 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
end
end
def with_connection
def with_connection(&block)
pool = ActiveRecord::Base.establish_connection
connection = pool.connection
yield(connection)
pool.with_connection(&block)
ensure
connection.close
pool.disconnect!
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment