Forum: Ruby on Rails Multiple HABTM to one table

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David C. (Guest)
on 2006-02-19 19:26
(Received via mailing list)
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
David C. (Guest)
on 2006-02-19 21:52
(Received via mailing list)
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
Jason P. (Guest)
on 2006-02-19 22:10
(Received via mailing list)
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.
removed_email_address@domain.invalid

"The computer allows you to make mistakes
faster than any other invention, with the
possible exception of handguns and tequila."
David C. (Guest)
on 2006-02-19 22:22
(Received via mailing list)
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.
David C. (Guest)
on 2006-02-20 00:33
(Received via mailing list)
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.
This topic is locked and can not be replied to.