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 

预先感谢任何帮助

回答

0

我意识到,我的模型是不是真正的问题,这个问题是与测试这些modles我仍然似乎可以得到正确的,但我认为我问的代码实际上是功能