Исследование имеет много вопросов, на которые есть ответы на многие вопросы:Неопределенный метод викторины модели
class Survey < ActiveRecord::Base
has_many :questions, :dependent => :destroy
accepts_nested_attributes_for :questions, :reject_if => -> (a) {a[:content].blank? }, :allow_destroy => true
end
class Question < ActiveRecord::Base
belongs_to :survey
has_many :answers, :dependent => :destroy
accepts_nested_attributes_for :answers, :reject_if => -> (a) {a[:content].blank? }, :allow_destroy => true
end
class Answer < ActiveRecord::Base
belongs_to :question
end
в SurveysController, я делаю это:
def show
@survey = Survey.find(params[:id])
@questions = @survey.questions
@answers = @questions.answers
end
и я получаю сообщение об ошибке:
undefined method `answers' for #<Question::ActiveRecord_Associations_CollectionProxy:0x007f7f68af6948>
и рельсы указывают на эту линию как проблему: @answers = @questions.answers
Почему?
я получаю сейчас. Спасибо! –