Forum: Ruby on Rails Model extension

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Kyku (Guest)
on 2007-03-14 14:58
Hello all, I'm working on optimising database accesses in my Rails

I'm having a master model and a logging model. For each master there may
be many logging objects, so the master has_many logging objects and the
logging object belongs_to master object.

I'd like to quickly fetch the most recently received logging object  for
a master, preferably within a join, so that I can sort and filter in SQL
rather than in Rails. But I can't simply use :include => logging model
because there are many of the for a single master.

Is there some possible and elegant solution/workaround of this problem
in Rails?
I'm currently replicating the most recently received loging object for
each machine in a separate table, but since the database is updated by
other programs I'm afraid of consitency errors.
This topic is locked and can not be replied to.