Multiple HABTM to one table

I have a class Player, and a class Game.

Game has two HABTM relationships to the Player table through seperate
relationship tables.

class Game < ActiveRecord::Base
has_and_belongs_to_many :players, :uniq => true
has_and_belongs_to_many :victors, :class_name => ‘Player’, :uniq =>
true
end

When I add Player A to players, and Player B to victors, and save the
game,
there is no INSERT for games_victors, but there is for games_players. I
cannot figure out why this is so.

Furthermore, when I load the game, there are two SELECTs with JOINS to
GAMES_PLAYERS, instead of one for GAMES_PLAYERS and one for
GAMES_VICTORS.

What have I done wrong?

David

Further investigation shows that at least part of this has been fixed
(Changeset #3331) in the TRUNK version. What’s the best way to run a
Rails
app with a version from subversion?

David

On Feb 19, 2006, at 7:38 AM, David C. wrote:

Further investigation shows that at least part of this has been fixed
(Changeset #3331) in the TRUNK version. What’s the best way to
run a Rails
app with a version from subversion?

Checkout Rails from svn into the vendors directory of the application
and then keep it up to date though out the development of the
project, freezing the Rails checkout on launch. We just had a q & a
session with DHH and this is how 37Signals develops their apps.


Jason P.
[email protected]

“The computer allows you to make mistakes
faster than any other invention, with the
possible exception of handguns and tequila.”

On Sunday 19 February 2006 09:08 am, David C. wrote:

On Sunday 19 February 2006 08:38 am, David C. wrote:

Further investigation shows that at least part of this has been fixed
(Changeset #3331) in the TRUNK version. What’s the best way to run a
Rails app with a version from subversion?

OK. Even running with the trunk version, I’m having a problem. I get
three INSERTs total, one for GAME, and two for GAMES_PLAYERS, but none for
GAMES_VICTORS.

For the record, this one was in my code. I need to specify the
join_table on
the second HABTM. Of course, I blame the documentation for not
discussing
the default. I’ve submitted a patch for it.

On Sunday 19 February 2006 08:38 am, David C. wrote:

Further investigation shows that at least part of this has been fixed
(Changeset #3331) in the TRUNK version. What’s the best way to run a
Rails app with a version from subversion?

OK. Even running with the trunk version, I’m having a problem. I get
three
INSERTs total, one for GAME, and two for GAMES_PLAYERS, but none for
GAMES_VICTORS.