Skip to content

Instantly share code, notes, and snippets.

@wykhuh
Last active June 8, 2018 20:52
Show Gist options
  • Save wykhuh/58f33a07ccdefaf23dbc5c553a521989 to your computer and use it in GitHub Desktop.
Save wykhuh/58f33a07ccdefaf23dbc5c553a521989 to your computer and use it in GitHub Desktop.
Ruby: splat array with string interpolation
# https://bugs.ruby-lang.org/issues/10930
ids = [1, 2, 3]
sql = "SELECT * FROM table WHERE id IN (#{ids.to_s[1..-2]})"
ActiveRecord::Base.connection.execute(sql)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment