require "csv" class TartifletteScoreExportService def self.generate_csv CSV.generate(headers: true) do |csv| csv << [ "Identifiant", "Critère", "Score", "Session", "Création" ] Tartiflette.all.each do |tartiflette| tartiflette.scores.each do |score| csv << [ tartiflette.scoring_id, score.scoring_criterium.name, score.value, score.session_id, score.created_at ] end end end end end