Created
October 27, 2013 16:33
-
-
Save harssh/7184648 to your computer and use it in GitHub Desktop.
Rails: Validate unique combination of multiple columns
This file contains hidden or 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
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