私は Ruby on Rails にかなり慣れていないので、アクティブなレコード関連付けの問題を抱えていることは明らかですが、自分で解決することはできません。
関連付けられた 3 つのモデル クラスがあるとします。
# application_form.rb
class ApplicationForm < ActiveRecord::Base
has_many :questions, :through => :form_questions
end
# question.rb
class Question < ActiveRecord::Base
belongs_to :section
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 :answers, :through => :form_question_answers
end
しかし、コントローラを実行してアプリケーション フォームに質問を追加すると、次のエラーが発生します。
ActiveRecord::HasManyThroughAssociationNotFoundError in Application_forms#show
Showing app/views/application_forms/show.html.erb where line #9 raised:
Could not find the association :form_questions in model ApplicationForm
誰かが私が間違っていることを指摘できますか?