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', :conditions => { :benched => true }

(not sure if this is 100% of what you need, but you get the idea)

On the other hand, if a player really can only be on one team, you'll
have a much better time if you switch back to a plain has_many. On the
other hand, if you've got a situation where players *can* be on
multiple teams, it's possible that they could be "benched" only on
some of them; in that case, you'll want a "decorated join model", with
has_many :through.

--Matt Jones


On Mar 2, 9:04 am, Frank Kim <railso...@gmail.com> wrote:
> 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

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to