method

with_debug

with_debug()
public

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