Forum: Ruby on Rails habtm find question

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.
Koalemos (Guest)
on 2007-08-02 10:34
(Received via mailing list)
The model "Raids" and "Characters" have a habtm relationship. I'm
having a tough time finding all the characters who have attended a
raid in the last week. I have a timestamp column in the raids table.

Its easy to grab all the raids each char has attended in the last week
but i cant think of how to get all the characters.

Thanks in advance.
Pratik N. (Guest)
on 2007-08-02 15:17
(Received via mailing list)
You might want to use has_many :through and put the timestamp in join

On 8/2/07, Koalemos <removed_email_address@domain.invalid> wrote:
> >

- Pratik
Koalemos (Guest)
on 2007-08-03 08:44
(Received via mailing list)
Having the timestamp in the join table seems redundant and not very
rails like since the timestamp would be the same for every row which
points to a particular raid. while it would allow me to do something
has_many :recent_chars, :though => :join, :source =>:raid, :conditions
=> 'timestamp <= 1.week.ago' (assuming this is even correct)

with my inexperience i'm not sure if that is the best way to go about
doing things.
This topic is locked and can not be replied to.