I have two tables: ‘owner_changes’, ‘tasks’
‘tasks’ has a primary key of ‘id’. ‘owner_changes’ uses a ‘task_id’
foreign key to relate the tables. ‘owner_changes’ contains records for
every instance of a task owner change. ‘owner_changes’ also houses a
‘comment’ column to store any comments one task owner may wish to leave
I have a mailer model set up that delivers an email to the current task
owner. So far, I’ve been very pleased with this set up; it’s simply
worked without fail and my code is tight. The mailing process is
controlled by a ‘before_update’ method atop the mailer model. Here lies
the issue: a task can have multiple owner changes, an owner change can
only belong to one task. Thus, a task can have multiple comments.
Obviously, the most current owner is only concerned about the comment
that was sent to him/her. I used a simple array method (.last) to bring
the last comment from the ‘owner_change’ array. This doesn’t display the
latest comment. I understand that problem, but I’m not sure what the
best way to approach this would be.
If I’ve not been clear enough in my description, which is likely, please
specify what you’d like me to elaborate on.