私はこれらの3つのモデルを持っています
class User < ActiveRecord::Base
has_many :answers, :as => :owner
end
class Answer < ActiveRecord::Base
belongs_to :owner, :polymorphic => true
has_one :test
end
class Test < ActiveRecord::Base
belongs_to :answer
end
そのため、モデル間に新しい関連付けを作成する必要なく、モデルを介してモデルTest
をモデルに関連付けたいので、次をテストモデルに入れます。User
Answer
has_one :owner, :through => :answer
しかし、それは機能せず、このエラーが発生しました
ActiveRecord::HasManyThroughAssociationPolymorphicSourceError: Cannot have a has_many :through association 'Test#owner' on the polymorphic object 'Owner#owner'.
助けはありますか?