validates_uniqueness_of on two columns?

I want to make sure a combination of email and name are
unique in a database for a newsletter signup application

What would be the railsy-ish way to do it?

here are a couple of ways I can think of accomplishing this

o Extend validation

o Make a unique primary key column in the database

Clayton Cottingham

WinterMarket Networks

Phone: (604) 417-3254

Vancouver, B.C. Canada

http://www.wintermarket.net

MSN:drfrog666@hotmail.com

AIM:drfrogrx

I'm not sure if writing a validate method is considered "extending
validation", but that's the way I'd do it. And also a DB constraint;
just in case. It protects the integrity of your data regardless of
how it got there, since not all paths may be through your application.

Clayton Cottingham wrote the following on 17.09.2006 23:11 :

I want to make sure a combination of email and name are unique in a database for a newsletter signup application

What would be the railsy-ish way to do it?

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 ... ]

Lionel