Validates_uniqueness_of AND join tables

I have organizations and individuals. Both of these can have multiply
urls, emails, addresses or phones…so I have used a join table. I also
have codes - WK - work, HM - Home…etc. I need to validate that an
individual or oranization can only have one type of email, phone…etc.

For example an individual can only have multiple email address but only
one with type “WK”. How would I validate this accross the join table.

In the email model I have this:

validates_uniqueness_of :type_cd, :scope => “individual_id”

but it doesn’t seem to know about individual_id in this context???

thanks

The validation must be paced on the join table

you’ll need to validate the uniquness of the two id’s and a type field.