マスメディア形式で所有者のリストを返すこのコード行 <%= f.collection_select :owner_ids, Owner.order(:id), :id, :name, {}, {multiple: true} %>
をフォームに入れましたが、このフィールドにも会社を含める必要があるため、同じリストに会社も含めることができ、マスメディア シャネルが所有される可能性があります人によって、または会社によって。
会社.rb
class Company < ActiveRecord::Base
has_many :ownerships
has_many :massmedia, through: :ownerships
has_many :owners, through: :ownerships
end
オーナー.rb
class Owner < ActiveRecord::Base
has_many :ownerships
has_many :massmedia, through: :ownerships
has_many :companies, through: :ownerships
end
Massmedium.rb
class Massmedium < ActiveRecord::Base
belongs_to :category
has_many :ownerships
has_many :owners, through: :ownerships
has_many :companies, through: :ownerships
end