--0-287761359-11892032133660
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

Toby,

Seeing as ActiveRecord is part of Rails, you ought to post this question to the "Ruby on Rails: Talk" group.

----- Original Message ----
From: Toby O'Rourke <ruby / tobyandbecswedding.info>
To: ruby-talk ML <ruby-talk / ruby-lang.org>
Sent: Friday, September 7, 2007 3:59:53 PM
Subject: enforce mutual exclusivity

Hi,

First post, sorry if this is the wrong place or has been answered before.

I'm using ActiveRecord and I want to enforce mutual exclusivity on a 
has_and_belongs_to_many.

A concrete example: I have a User which can have one or more Roles 
(student, tutor, headmaster, administrator etc). However if a user is a 
student they cannot hold any other role. I was hoping to find something 
like validate_exclusive but that doesn't appear to exist. Can anyone 
suggest how I can implement this. Otherwise, is there  a better pattern 
I could use to model this?

Many thanks,

Toby.










       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
--0-287761359-11892032133660--