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 ...@@ -31,13 +31,10 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration
end end
end end
def with_connection def with_connection(&block)
pool = ActiveRecord::Base.establish_connection pool = ActiveRecord::Base.establish_connection
connection = pool.connection pool.with_connection(&block)
yield(connection)
ensure ensure
connection.close pool.disconnect!
end end
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