instance method with_debug

Ruby on Rails 8.1.2

Since v8.1.2

Signature

with_debug()

Temporarily enables debug mode for the duration of the block. Calls to debug will only be reported if debug mode is enabled.

Rails.event.with_debug do
  Rails.event.debug("sql.query", { sql: "SELECT * FROM users" })
end
Source
# File activesupport/lib/active_support/event_reporter.rb, line 410
    def with_debug
      prior = Fiber[:event_reporter_debug_mode]
      Fiber[:event_reporter_debug_mode] = true
      yield
    ensure
      Fiber[:event_reporter_debug_mode] = prior
    end

Defined in activesupport/lib/active_support/event_reporter.rb line 410 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::EventReporter

Type at least 2 characters to search.

↑↓ navigate · open · esc close