活动管理输入字段动态生成

时间:2016-12-08 05:03:33

标签: ruby-on-rails activeadmin has-and-belongs-to-many

我有以下模型关联:

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,我需要为问题生成该数量的输入字段。有没有办法实现这个目标?

0 个答案:

没有答案