ActiveRecord::HasManyThroughAssociationPolymorphicSourceError

淺唱寂寞╮ 提交于 2019-12-05 08:09:44

I think you need to be more specific in defining your relationships in your Player model. For example:

class Player < ActiveRecord::Base
  has_many :player_structures
  has_many :structureas, :through => player_structures, :source => :structure, :source_type => 'StructureA'
  has_many :structurebs, :through => player_structures, :source => :structure, :source_type => 'StructureB'
end

Then you can make a method that'll return all the structures defined in the relationships instead of having to access each one individually.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!