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.