自定义ActiveAdmin CSV

时间:2019-02-22 08:25:26

标签: ruby-on-rails csv activeadmin

我正在使用Activeadmin,并且想在同一CSV文件中导出关联的模型值。我可以得到结果,但格式不正确。 我希望所有的问题都是列名,并在行中显示答案。有人可以帮我吗?

Papplication.rb

ActiveAdmin.register Papplication do
 csv do
  column "Questions" do |papp|
    @questions.map do |question|
      question.question_text
    end
  end
  column "Answers" do |papp|
    @questions = Question.where(:program_id=>papp.program_id)
    @answers = Answer.where(:question_id => @questions.ids,:startup_id => papp.startup_id)
    @questions.map do |question|
        Answer.where(:question_id => question.id, :startup_id => @startup.id).first.answer_text
    end
  end
end

Downloaded csv looks this

Expected Result

0 个答案:

没有答案