hum, well yes the relations is for  a game to have many teams , but no for
teams to be able to be involve in many game, is just that its not very clear
what the requirements are and took this relation a a guide

table games:
team1_id
team2_id

is a game having the id of 2 teams specifically.

i see you want to have teams involve in many games also, it appears you want
to save the designations per game, because if you keep the designation in
the teams table when a team is designation is edited it will change
designations for pass games, so the best way to do it is to have a has many
through relation with a designation table linking to the game and team
table.


class Game < ActiveRecord::Base
has_many  :designations
has_many :teams , :through => designations


class Team < ActiveRecord::Base
has_many :designations
has_many :games , :through => designations


class designation < ActiveRecord::Base
belongs_to :game
belongs_to :team


Designations are now per team and per game so if you update a game or a
team, designations in the past wont be affected.
if you want to save more details per team and per game , change the name of
the designation table to something more general
and add all the fields that will be specific to the game played by those
teams, like if is baseball, you can put the score, the homeruns and so on.
You could call the table statistics or something like that.


you can call a designation for a game with

first get a game from the DB

@game = Game.find(params[:id])

@designations = @game.designations

to see how this kind of relations are made you can watch this railscasts

http://railscasts.com/episodes/47-two-many-to-many

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to