Add ConnectionPoolWithConnection as middleware to application if ActiveRecord and thin are used, fixes #1749

ref #1749
This middleware will fix the problem.
Feel free to commit to this branch (I think the name of middleware can be better than now...).