【发布时间】:2011-05-17 23:26:21
【问题描述】:
我最近一直在从事一个项目,其中玩家可以创建团队并成为团队所有者,但玩家也可以通过名为 Squad 的单独表格成为团队的一部分。
class Player
has_many :teams
has_many :squads
end
class Squad
belongs_to :player
belongs_to :team
end
class Team
belongs_to :owner, :class_name => "Player"
has_many :squads
has_many :players, :through => "squads"
end
我不知道这是否就是我制作我想要的东西所需要的全部,但我就是想不通。我如何让玩家通过 Squad 请求被邀请加入团队,而团队所有者对该玩家回答是或否?如果是,他会加入 Table Squad 并成为团队的一员。如果没有,他的请求就被销毁了。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 associations rails-models