# Re: enforce mutual exclusivity

**URL:** <https://www.ruby-forum.com/t/re-enforce-mutual-exclusivity/114112>\
**Category:** Ruby\
**Created:** [September 8, 2007, 12:14am UTC](https://www.ruby-forum.com/t/re-enforce-mutual-exclusivity/114112 "2007-09-08T00:14:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [September 8, 2007, 12:14am UTC](https://www.ruby-forum.com/t/re-enforce-mutual-exclusivity/114112/1 "2007-09-08T00:14:55Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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.
