andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-06 17:55 UTC
Confused setting up relationships...
Hi everyone, I am working on a new project which will implement a bracket based tournament system, like the NCAA finals. The entrants will be assigned to brackets, users will vote, the winner goes on, the looser goes home. :) I am having a little difficulty setting up the relationships for my objects. So far I have the following objects in mind... Tournament = The overall container that will define the parameters of the tournament. Round = One of the individual one-on-one contests between two teams. Entry = Details on the team itself. Vote = User votes cast during each round The associations I have in mind are: Tournament << has_many :rounds Round << belongs_to :tournament has_many :entries Entry << belongs_to :round has_many :votes Vote << belongs_to :entry So far so good... but I also need to associate the vote with the round. Each entry will have lots of votes, but the votes from one round shouldn''t count towards the next round. I thought about: Round << has_many :votes, :through => :entries But that didn''t seem quite right. Any help provided will be greatly appreciated. As an aside, does anyone know of any good resources (on-line or print) for getting my head around this kind of thinking? For some reason I just never seem to get my associations right, and I think it has more to do with not having the fundamentals down (unspecific to rails). Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Andrew, Just a quick thought... On Dec 6, 2007, at 11:55 AM, andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> So far I have the following objects in mind... > > Tournament = The overall container that will define the parameters of > the tournament. > Round = One of the individual one-on-one contests between two teams. > Entry = Details on the team itself. > Vote = User votes cast during each round >I''d probably say that a "Round" is a collection of "Contest", the contest being between two teams. So a Tournament has many rounds (Sweet Sixteen, Elite Eight, Final Four, etc), and a Round has many contests, and a contest has many (well, two) entries. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Phillip Koebbe wrote:> Hi Andrew, > > Just a quick thought... > > On Dec 6, 2007, at 11:55 AM, andrew.ohnstad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > >> So far I have the following objects in mind... >> >> Tournament = The overall container that will define the parameters of >> the tournament. >> Round = One of the individual one-on-one contests between two teams. >> Entry = Details on the team itself. >> Vote = User votes cast during each round >> > > I''d probably say that a "Round" is a collection of "Contest", the > contest being between two teams. So a Tournament has many rounds > (Sweet Sixteen, Elite Eight, Final Four, etc), and a Round has many > contests, and a contest has many (well, two) entries. > > Peace, > Philliphere is help on associations. let me know what you think or if it helps. http://gemblon.com/railshowto/?p=19#more-19 -- 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-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 -~----------~----~----~----~------~----~------~--~---