lib: fix db connections leak

::ActiveRecord::Base.connection.close only returns the connection to the ActiveRecord pool
(a simple array to poll from). Since there is no reaper, this is a source of leaks.
This changes after_request to remove the connection from ActiveRecord's pool and eventually
call close on the connection (which makes it return to c3p0).

Don't forget to also set the :pool configuration parameter to increase ActiveRecord's pool.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
active_merchant: fix API queries multi-tenancy mode

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>