Dear Rails L.,
I am new on the list so will assume straight away that this question has
been
answered before. As I can see no immediate way of searching the list, I
will
ask the question. I apologize in advance for any disruption this may
cause.
Question time:
I am trying to write a web application for the staff at my office to
play a
form of virtual Super14. Its a bit like any of the virtual sports
available
on the internet except this one is for Rugby.
The relevant tables in my database are as follows:
create table teams (
id INT AUTO_INCREMENT NOT NULL,
name VARCHAR(40),
PRIMARY_KEY(id) );
create table games (
id INT AUTO_INCREMENT NOT NULL,
date DATETIME, #Date of game
home_teams_id INT, #id of home team
away_teams_id INT, #id of away team
home_team_score INT, #this is not meant to link to another table
away_team_score INT, #this is not meant to link to another table
PRIMARY_KEY (id) );
In this example the home and away team records in games are supposed to
link
to a team record in teams.
In the models, I was thinking that the game model would include,
“has_many :teams”
and the team model would include, “belongs_to :game”
When I then look at the scaffold list for Games the home and away teams
do not
show up.
Is there a better way to name the home and away team_id’s in the games
table
that will fix this?
or is there another more elegant way to handle this.
Thanks for your patience reading this and I look forward to hearing from
you,
Dave Latham
@NewZealand.Auckland