0
兩次我有兩個類Intern::Question
和Intern::Answer
,標準協會的樣子:同事同型號的mongoid
class Intern::Question
has_many :intern_answers, class_name: 'Intern::Answer'
end
class Intern::Answer
belongs_to :intern_question, class_name: 'Intern::Question'
end
,現在我想引用兩次回答belongs_to的問題,答案可以存儲父母的問題和未來問題是這樣的:
class Intern::Question
has_many :intern_answers, class_name: 'Intern::Answer'
has_many :node_for_answers, class_name: 'Intern::Answer'
end
class Intern::Answer
belongs_to :intern_question, foreign_key: :intern_question_id, class_name: 'Intern::Question'
belongs_to :next_question, foreign_key: :next_question_id, class_name: 'Intern::Question'
end
但我不得不嘗試,並獲得此錯誤:
Mongoid::Errors::AmbiguousRelationship
@muistooshort抱歉錯字.. – itx