Pale Horse wrote:
> 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
> the next.
> 
> 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.

Use :order to put the records into the order you want.  Unless you do 
that, the DB will return records in an unpredictable sequence.
> 
> If I've not been clear enough in my description, which is likely, please
> specify what you'd like me to elaborate on.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to