About ruby on rails, hackintosh, iphone3g and etc.

Wednesday, February 4, 2009

Rails Validate More than 1 Primary Key

In Ruby on Rails, you can specify your model class to validate uniqueness of multiple columns (multiple primary key). Here is the command:

validates_uniqueness of :email, :scope => :name

if you want to validate uniqueness of a triplet or more

validates_uniqueness of :first_attr, :scope => [ :second_attr,
:third_attr ... ]

No comments: