Skip to content

Instantly share code, notes, and snippets.

@justinko
Created October 13, 2010 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinko/624700 to your computer and use it in GitHub Desktop.
Save justinko/624700 to your computer and use it in GitHub Desktop.
# Instead of this:
name = 'Justin'
Person.where('name = ? OR display_name = ? OR cool_name = ? OR alias = ?', name, name, name, name)
# You can do
name = 'Justin'
Person.where('name = ? OR display_name = ? OR cool_name = ? OR alias = ?', *[name]*4)
# Maybe this borders on DRY and clarity?
# UPDATE:
# Woops, totally forgot you can do this:
name = 'Justin'
Person.where('name = :name OR display_name = :name OR cool_name = :name OR alias = :name', :name => name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment