Skip to content

Instantly share code, notes, and snippets.

@salvadorgascon
Created April 9, 2023 14:03
Show Gist options
  • Save salvadorgascon/d1cb9d1bb7d7c780df15ab622c610a82 to your computer and use it in GitHub Desktop.
Save salvadorgascon/d1cb9d1bb7d7c780df15ab622c610a82 to your computer and use it in GitHub Desktop.
Run a sql statement with parameters for PostgreSQL in Ruby on Rails
statement =
<<-SQL
UPDATE customers set search_text = CONCAT(code,' ',name) where id = $1
SQL
ActiveRecord::Base.connection.raw_connection.exec_params(statement, [id])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment