如何在帖子中显示多队结果(球员)! Ruby On Rails

时间:2015-05-07 09:54:13

标签: ruby-on-rails-4 many-to-many

如何在帖子中显示多个(团队)结果(玩家

我已经有一篇帖子以及多人团队这篇文章就像在这张图片中一样

post

我之前可以查看的问题是How to use Many to Many Relationship posts#show In ruby on rails。现在我像这样使用团队和玩家:

玩家#模型

class Player < ActiveRecord::Base
  belongs_to  :team
end

Teams#Model

class Team < ActiveRecord::Base
  has_many :players

  has_many :postteams
  has_many :posts, :through => :postteams

end

Postteam#Model

class Postteam < ActiveRecord::Base
  belongs_to :post
  belongs_to :team
end

现在我想在这些小组中使用玩家<控制器显示这些团队成绩(玩家)

players

0 个答案:

没有答案