更新时间:2023-11-17 16:53:16
在ApplicationForm 类中,需要指定ApplicationForms 与'form_questions' 的关系.它还不知道.在您使用 :through
的任何地方,您都需要先告诉它在哪里可以找到该记录.你的其他课程也有同样的问题.
In the ApplicationForm class, you need to specify ApplicationForms's relationship to 'form_questions'. It doesn't know about it yet. Anywhere you use the :through
, you need to tell it where to find that record first. Same problem with your other classes.
所以
# application_form.rb
class ApplicationForm < ActiveRecord::Base
has_many :form_questions
has_many :questions, :through => :form_questions
end
# question.rb
class Question < ActiveRecord::Base
belongs_to :section
has_many :form_questions
has_many :application_forms, :through => :form_questions
end
# form_question.rb
class FormQuestion < ActiveRecord::Base
belongs_to :question
belongs_to :application_form
belongs_to :question_type
has_many :form_questions_answers
has_many :answers, :through => :form_question_answers
end
假设您就是这样设置的.
That is assuming that's how you have it set up.