# Associations

**URL:** <https://www.ruby-forum.com/t/associations/180236>\
**Category:** Rails\
**Created:** [December 15, 2009, 11:24am UTC](https://www.ruby-forum.com/t/associations/180236 "2009-12-15T11:24:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [December 15, 2009, 11:24am UTC](https://www.ruby-forum.com/t/associations/180236/1 "2009-12-15T11:24:53Z")

</div>

Wondering if anyone can help me with a few database tables I need  
associating properly?

I have 2 tables. ‘adam\_tasks’ and ‘adam\_task\_comments’.

> adam\_task.rb:

class AdamTask \< ActiveRecord::Base

belongs\_to :owner, :class\_name =\> ‘User’, :foreign\_key =\> :owner\_id  
belongs\_to :creator, :class\_name =\> ‘User’, :foreign\_key =\>  
:creator\_id  
belongs\_to :project

has\_many :adam\_task\_comments, :dependent =\> :destroy

> adam\_task\_comment.rb:

class AdamTaskComment \< ActiveRecord::Base

include Tp2Mixin

belongs\_to :adam\_task

Each Task can have multiple comments. At the moment, I have one column  
in the adam\_tasks table that appends owner.name in a single string:  
“Name, Name, Name” called ‘previous\_owners’.

I should have atomised my data so that each owner can be accessed  
individually. I’m doing this by adding two more columns to my  
adam\_task\_comments table: ‘sender\_id’, ‘receiver\_id’. These two columns  
will hold the IDs for the sender and receiver from the ‘users’ table.

The reason I am doing this is so that I can email every person involved  
when the task is completed.

Am I on the right lines or can someone help me a little further?

Thank you.

---

<div class="post-metadata">

**Author:** ![mercurius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@mercurius](https://www.ruby-forum.com/u/mercurius)\
**Post date:** [December 15, 2009, 4:20pm UTC](https://www.ruby-forum.com/t/associations/180236/2 "2009-12-15T16:20:53Z")

</div>

Problem solved - nevermind.
