0
我想建立一組關係,看起來像下面的代碼 主要的事情,我認爲我的問題是在SomethingThatNeedsAnAnswer類,我想與多態模型的關係使用名稱是超過它的類名不同Mongoid複雜多態關係
Class Votable
has_many :votes
belongs_to :question, polymorphic: true
end
Class Vote
belongs_to :selected_answer, polymorphic: true
belongs_to :votable
end
Class SomethingThatNeedsAFewAnswers
has_one :some_question, class_name: "Votable", as :question
has_one :some_other_question, class_name: "Votable", as :question
end
Class ExampleAnswerClass
field :some_text_field
has_many: votes: as :selected_answers
end
預先感謝任何幫助