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 [email protected]
To: ruby-talk ML [email protected]
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.