# Habtm find question

**URL:** <https://www.ruby-forum.com/t/habtm-find-question/111056>\
**Category:** Rails\
**Created:** [August 2, 2007, 8:34am UTC](https://www.ruby-forum.com/t/habtm-find-question/111056 "2007-08-02T08:34:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Koalemos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@Koalemos](https://www.ruby-forum.com/u/Koalemos)\
**Post date:** [August 2, 2007, 8:34am UTC](https://www.ruby-forum.com/t/habtm-find-question/111056/1 "2007-08-02T08:34:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Koalemos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@Koalemos](https://www.ruby-forum.com/u/Koalemos)\
**Post date:** [August 2, 2007, 1:17pm UTC](https://www.ruby-forum.com/t/habtm-find-question/111056/2 "2007-08-02T13:17:45Z")

</div>

You might want to use has\_many :through and put the timestamp in join  
table.

On 8/2/07, Koalemos [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Cheers!

- Pratik  
[http://m.onkey.org](http://m.onkey.org)

---

<div class="post-metadata">

**Author:** ![Koalemos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@Koalemos](https://www.ruby-forum.com/u/Koalemos)\
**Post date:** [August 3, 2007, 6:44am UTC](https://www.ruby-forum.com/t/habtm-find-question/111056/3 "2007-08-03T06:44:01Z")

</div>

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  
like:  
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.
