# Non Master

**URL:** <https://www.ruby-forum.com/t/non-master/72045>\
**Category:** Rails\
**Created:** [October 13, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/non-master/72045 "2006-10-13T21:14:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 9:14pm UTC](https://www.ruby-forum.com/t/non-master/72045/1 "2006-10-13T21:14:39Z")

</div>

How to handle a non-master table which is a mapping between 3 master  
tables. I have defined the appropriate has\_and\_belongs\_to\_many  
associations but when I enter data for a course I get 2 entries in  
course\_prerequisites table  
1 2 null  
1 null 3

Basically I am not able to make ROR understand that group\_id and  
exam\_id that I am entering belong to a single tuple.  
Any solution?

Kumar.

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 10:27pm UTC](https://www.ruby-forum.com/t/non-master/72045/2 "2006-10-13T22:27:11Z")

</div>

Can I get more specific answer? ☹

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 10:05pm UTC](https://www.ruby-forum.com/t/non-master/72045/3 "2006-10-13T22:05:03Z")

</div>

On 10/13/06, Kumar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> exam\_id that I am entering belong to a single tuple.  
> Any solution?

The most straight way is to introduce another model for that non-master  
table. It’s not about just creating another AR class, but adjusting your  
vision of the problem domain.  
Then you’ll be able to use has\_many :through (if it will be still be  
needed).

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 10:33pm UTC](https://www.ruby-forum.com/t/non-master/72045/4 "2006-10-13T22:33:40Z")

</div>

On 10/14/06, Kumar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can I get more specific answer? ☹

I doubt you can without being more specific about your problem.

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 10:45pm UTC](https://www.ruby-forum.com/t/non-master/72045/5 "2006-10-13T22:45:58Z")

</div>

No doubt… I mean I didnt got that answer correctly.  
Want in detail. ☹

Kumar

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 10:27pm UTC](https://www.ruby-forum.com/t/non-master/72045/6 "2006-10-13T22:27:11Z")

</div>

Can I get more specific answer? ☹

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [October 13, 2006, 10:56pm UTC](https://www.ruby-forum.com/t/non-master/72045/7 "2006-10-13T22:56:03Z")

</div>

On 10/14/06, Kumar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> No doubt… I mean I didnt got that answer correctly.  
> Want in detail. ☹

E.g, you have models A, B and C and a “non-master” table to link them  
together.

Then you can create model D that will represent some meanful entity in  
your  
A / B / C model. Then you can do “A has\_many :bs, :through =\> :d” and  
vice  
versa.
