From 3602f4f0ea19416fd1ef0128a9b5710b249cb1f4 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 12 Nov 2015 11:28:06 +0100 Subject: [PATCH] Also allow db connections for pre & post. --- lib/sessions/event.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/sessions/event.rb b/lib/sessions/event.rb index 65ee8f66f..8f72fa3e7 100644 --- a/lib/sessions/event.rb +++ b/lib/sessions/event.rb @@ -10,14 +10,19 @@ class Sessions::Event return { error: "No such event #{event}" } end + ActiveRecord::Base.establish_connection instance = backend.new(data, session, client_id) pre = instance.pre - return pre if pre - ActiveRecord::Base.establish_connection + if pre + ActiveRecord::Base.remove_connection + return pre + end result = instance.run - ActiveRecord::Base.remove_connection post = instance.post - return post if post + if post + ActiveRecord::Base.remove_connection + return post + end result end