# Help with modelling ActiveRecord associations

**URL:** <https://www.ruby-forum.com/t/help-with-modelling-activerecord-associations/105297>\
**Category:** Rails\
**Created:** [May 28, 2007, 4:45pm UTC](https://www.ruby-forum.com/t/help-with-modelling-activerecord-associations/105297 "2007-05-28T16:45:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![croxmeister](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/53a042/32.png) [@croxmeister](https://www.ruby-forum.com/u/croxmeister)\
**Post date:** [May 28, 2007, 4:45pm UTC](https://www.ruby-forum.com/t/help-with-modelling-activerecord-associations/105297/1 "2007-05-28T16:45:34Z")

</div>

I have been messing about with Rails and ActiveRecord for a while now,  
and I have had great success in the simple cases. But I have hit a  
stumbling  
block when it came to modelling a non-trivial problem domain.

I had hoped to absorb the knowledge by example, but fundamentally I  
don’t  
grok the more sophisticated associations and more importantly when to  
use them.

My background isn’t in DB designs. I went looking for something that  
could help  
me with the design related stuff from an ActiveRecord perspective (i.e.  
I know  
what I want my objects to look like and behave in terms of their  
associations,  
but how do I model that in the database).

Anyone know of any domain modelling resources with an ActiveRecord  
flavour?  
Preferably example heavy.

I suspect that I need to get down and dirty with HABTM, or has\_many  
through,  
but I don’t know when I need to use them.

If its any use, the problem I am trying to model is as follows.  
Its a software & hardware inventory system, services run on regular PCs  
but  
have a relationship with hardware devices. All are network accessible,  
but  
the hardware devices can have a relationship with hundreds of services,  
while  
the services can have a relationship with at most 6 hardware devices  
(domain  
specific constraints).

any help at all would be appreciated.

regards,  
Richard.
