我有以下模型关联:
class QuestionSet
attr_accessor :no_of_questions
has_and_belongs_to_many :questions
end
class Question
has_and_belongs_to_many :question_sets
end
问题集的主动管理页面如下:
ActiveAdmin.register QuestionSet do
...
form do |f|
...
f.input :no_of_questions, as: :select, collection: [1,2,3,4,5,6,7]
end
end
因此,基于所选的no_of_questions
,我需要为问题生成该数量的输入字段。有没有办法实现这个目标?