Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save harssh/7184648 to your computer and use it in GitHub Desktop.
Save harssh/7184648 to your computer and use it in GitHub Desktop.
Rails: Validate unique combination of multiple columns
The validation syntax where multiple columns combination is validated for uniqueness is :
validates_uniqueness_of :column_namae1, :scope => [:column_name2, :column_name3]
or even shorter in ruby 1.9.x:
validates_uniqueness_of :column_name1, scope: [:column_name2, :column_name3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment