Frederick Cheung wrote:
> On 11 Jul 2009, at 17:55, Rick wrote:
>
>>>
>> Team team;
>> Team opponent;
>>
>> would you just set up another belongs_to like:
>>
>> belongs_to :opponent, :class_name => "Team", :foreign_key =>
>> "opponent_id"
>
> That's what I would do (except that the :foreign_key is redundant
> here: rails will default to #{association_name}_id for a belongs_to )
>
> Fred
The opponents are the same teams listed in the teams table. They just
have not been identified yet.
What I see from a logical point of view - using motion....
A team id is found (florida)
A query is sent to schedules for (florida)
A dataset is retrieved for (florida)
Within that dataset are opponents for (florida)
Another query should be made against each opponent returned within the
first query finding their subsequent ID in the teams table.
How would I implement such a query? Define each returned opponent as a
param? Pass the param to another method within teams?
This is the issue I would like to see answered. I really should not
have to create another id column in my schedules for the opponents.
Why? It's redundant data.
Opponents are also Teams that have opponents in the schedules table...
There should be a way to cross check their name and find their id in
either the schedules table or the teams table. If you see my diagram
above it shows that Florida for instance has 12 opponents but you also
see that the team_id shows Florida as 10.
If I did a search for Florida St. they would have Florida as their week
12 opponent in the schedules table. So, this means that there is a team
name of Florida (somewhere in the schedules table) that already houses
an team_id of 10.
I just don't see why something like this is so difficult to achieve? I
can create the entire query in mysql but I shouldn't have to create a
complete mysql query in rails for something like this. I've defined the
relationships between these tables so they are associated. That means I
should be able to pull any data from either table at anytime..
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---