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. :slight_smile: 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!

Hi Andrew,

Just a quick thought…

On Dec 6, 2007, at 11:55 AM, [email protected] 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

Phillip K. wrote:

Hi Andrew,

Just a quick thought…

On Dec 6, 2007, at 11:55 AM, [email protected] 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

here is help on associations. let me know what you think or if it
helps.

http://gemblon.com/railshowto/?p=19#more-19

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs