Prettier raw SQL in ruby
Public
29 Nov 11:29

Use this syntax to format raw SQL nicely in ruby code. In some editors it also enables SQL syntax highlighting.

variable = <<-SQL.gsub(/\s+/, ' ')
  SELECT * FROM your_sql_code_here
SQL

The gsub is used to remove whitespace from logs.

Comments

Joe
aleksander
Well known but easilly to forget. Thanks @mus