Created
October 13, 2010 19:26
-
-
Save justinko/624700 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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