def logged_queries(&block)
      queries = []

      subscriber = ActiveSupport::Notifications
        .subscribe('sql.active_record') do |name, started, finished, id, payload|
        queries << payload[:sql]
      end

      block.call

      queries

      ensure ActiveSupport::Notifications.unsubscribe(subscriber)
    end
def logged_queries(&block)
      queries = []

      subscriber = ActiveSupport::Notifications
        .subscribe('sql.active_record') do |name, started, finished, id, payload|
        queries << payload[:sql]
      end

      block.call

      queries

      ensure ActiveSupport::Notifications.unsubscribe(subscriber)
    end
Logs the queries run inside the block, and return them.