Is there a way to validate the uniqueness of two or more fields in the same model? For example lets say that I have fields :name and :zip. An acceptable set would be {[name1, zip1], [name1, zip2]}but you can’t have {[name1,zip1],[name1,zip1]} in the same table.
Is there a rails validates method that can be used?
You should use
scope:See documentation and guide for more information.
You can use
:scopeoption to specify other attributes that are used to limit the uniqueness check.