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. --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You might want to use has_many :through and put the timestamp in join table. On 8/2/07, Koalemos <swimming.bird-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. > > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Aug 2, 5:16 am, Pratik <pratikn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You might want to use has_many :through and put the timestamp in join table. > > On 8/2/07, Koalemos <swimming.b...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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. > > -- > Cheers! > - Pratikhttp://m.onkey.org--~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---