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 a team is removed, then none of the players can theoretically
belong to that team.



On 2 March 2010 13:51, Matt Jones <al2o...@gmail.com> wrote:

> 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<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
Charles A. Lopez
charlesalo...@gmail.com

What's your vision for your organization?
What's your biggest challenge?

Let's talk.
(IBM Partner)

-- 
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