Skip to content

Commit 07aeec9

Browse files
committedJan 26, 2023
✨ use result of ActiveSupport::Notifications.subscribe to unsubscribe
1 parent 64025e0 commit 07aeec9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎lib/sql_spy.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def call(_name, start, finish, _message_id, values)
3939
def self.track
4040
tracker = Tracker.new
4141

42-
ActiveSupport::Notifications.subscribe("sql.active_record", tracker)
42+
subscriber = ActiveSupport::Notifications.subscribe("sql.active_record", tracker)
4343
yield
44-
ActiveSupport::Notifications.unsubscribe(tracker)
44+
ActiveSupport::Notifications.unsubscribe(subscriber)
4545

4646
tracker.queries
4747
end

0 commit comments

Comments
 (0)