Re: [Rails] Re: how I do different has_and_belongs_to_many for the same model?

2010-03-02 Thread Frank Kim
Frederick, That was the solution. Thanks! -Frank On Tue, Mar 2, 2010 at 6:01 AM, Frank Kim wrote: > Thanks Frederick, I forgot about that option. > > On Tue, Mar 2, 2010 at 3:00 AM, Frederick Cheung > wrote: >> >> >> On Mar 2, 5:47 am, Frank Kim wrote: >> >>> However when I do this: >>> >>> tea

Re: [Rails] Re: how I do different has_and_belongs_to_many for the same model?

2010-03-02 Thread Charles A. Lopez
The attribute (Matt Jones calls it a "condition") of being on the bench or not on the bench is a property of the player not the team. A team does not belong to the players. Players make up the team. Consider the deletion anomaly. If a Player is removed, does the team cease to exist? However, If

[Rails] Re: how I do different has_and_belongs_to_many for the same model?

2010-03-02 Thread Matt Jones
Not sure if has_and_belongs_to_many is exactly right (can a player be on more than one team?) but one option is to add :conditions to the declarations: has_and_belongs_to_many :benched_players, :join_table => 'teams_players', :association_foreign_key => 'player_id', :class_name => 'Player', :condi

Re: [Rails] Re: how I do different has_and_belongs_to_many for the same model?

2010-03-02 Thread Frank Kim
Hi Ar, The attribute idea makes a lot of sense. If I did it that way then I could use the same join table. However I would have to use specify custom SQL for how to select from it, right? Or is there a better way? -Frank On Tue, Mar 2, 2010 at 5:58 AM, Ar Chron wrote: > Some might argue that b

Re: [Rails] Re: how I do different has_and_belongs_to_many for the same model?

2010-03-02 Thread Frank Kim
Thanks Frederick, I forgot about that option. On Tue, Mar 2, 2010 at 3:00 AM, Frederick Cheung wrote: > > > On Mar 2, 5:47 am, Frank Kim wrote: > >> However when I do this: >> >> team.bench_players << player >> >> It saves it in the wrong table, i.e. the team_players table.  What am >> I doing w

[Rails] Re: how I do different has_and_belongs_to_many for the same model?

2010-03-02 Thread Ar Chron
Some might argue that being on the bench or not is simply an attribute of a player... benched or playing, the player is still on the team. -- 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