我有以下表格:<%= f. Collection_select :所有者_ids, Owner.order (:id), :id, :name,{},{multiple: real} %>
:将所有人名单归为中型表格,但在这方面,我也需要包括这些公司,因此,我也可以在同一名单上列出公司,因此,可造成一个人或一个公司拥有大众媒体。
<>Company>。
class Company < ActiveRecord::Base
has_many :ownerships
has_many :massmedia, through: :ownerships
has_many :owners, through: :ownerships
end
<>strong> Ownerrb
class Owner < ActiveRecord::Base
has_many :ownerships
has_many :massmedia, through: :ownerships
has_many :companies, through: :ownerships
end
<>Massmedium>。
class Massmedium < ActiveRecord::Base
belongs_to :category
has_many :ownerships
has_many :owners, through: :ownerships
has_many :companies, through: :ownerships
end