diff options
Diffstat (limited to 'actioncable/lib/action_cable/server/worker/active_record_connection_management.rb')
-rw-r--r-- | actioncable/lib/action_cable/server/worker/active_record_connection_management.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/actioncable/lib/action_cable/server/worker/active_record_connection_management.rb b/actioncable/lib/action_cable/server/worker/active_record_connection_management.rb new file mode 100644 index 0000000000..c1e4aa8103 --- /dev/null +++ b/actioncable/lib/action_cable/server/worker/active_record_connection_management.rb @@ -0,0 +1,19 @@ +module ActionCable + module Server + class Worker + module ActiveRecordConnectionManagement + extend ActiveSupport::Concern + + included do + if defined?(ActiveRecord::Base) + set_callback :work, :around, :with_database_connections + end + end + + def with_database_connections + connection.logger.tag(ActiveRecord::Base.logger) { yield } + end + end + end + end +end |