# HMT Help

**URL:** <https://www.ruby-forum.com/t/hmt-help/122349>\
**Category:** Rails\
**Created:** [December 6, 2007, 8:51pm UTC](https://www.ruby-forum.com/t/hmt-help/122349 "2007-12-06T20:51:17Z")\
**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:** [December 6, 2007, 8:51pm UTC](https://www.ruby-forum.com/t/hmt-help/122349/1 "2007-12-06T20:51:17Z")

</div>

Hello,

I’ve been asked to create an admin tool for an existing project. There  
are 2 tables that I need to work with all the time in this tool:  
displays and categories. These two tables have a many to many  
relationship, so I’ve added a third table, category\_displays. I’d like  
to be able to use the has\_many :through method to make this a lot  
easier to work with, however, the way the existing parts of this  
project are defined is making it difficult to do so.

Basically, categories are all divided up by suppliers, so there  
actually is no categories model (categories is a table that includes a  
field called supplierid). Instead, those that came before me defined a  
categories _module_ that, when a get\_instance method on it is called,  
returns a specific supplier class, which sets its table name to  
categories and is able to access the categories table. This makes it  
impossible to say (in the display model):

has\_many :category\_displays  
has\_many :categories, :through =\> :category\_displays

This is, once again, because there is no categories model, just a  
categories module. I know this is kind of a quirky design but I have  
to deal with it and try to change it as little as possible. Is there  
an easy way to get the has\_many :through association to work in this  
situation? Thanks.
