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.
37c332966b49eeb1d54eeefd3bc5ce97?d=identicon&s=25 David Corbin (Guest)
on 2006-02-19 18: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
37c332966b49eeb1d54eeefd3bc5ce97?d=identicon&s=25 David Corbin (Guest)
on 2006-02-19 20: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
2899cec9af525f7953e19c8210aca97c?d=identicon&s=25 Jason Perkins (Guest)
on 2006-02-19 21:10
(Received via mailing list)
On Feb 19, 2006, at 7:38 AM, David Corbin 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 Perkins
jperkins@sneer.org

"The computer allows you to make mistakes
faster than any other invention, with the
possible exception of handguns and tequila."
37c332966b49eeb1d54eeefd3bc5ce97?d=identicon&s=25 David Corbin (Guest)
on 2006-02-19 21:22
(Received via mailing list)
On Sunday 19 February 2006 08:38 am, David Corbin 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.
37c332966b49eeb1d54eeefd3bc5ce97?d=identicon&s=25 David Corbin (Guest)
on 2006-02-19 23:33
(Received via mailing list)
On Sunday 19 February 2006 09:08 am, David Corbin wrote:
> On Sunday 19 February 2006 08:38 am, David Corbin 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.