mercredi 2 décembre 2020

how to export csv file checkbox value into table in rails?

I want to checkbox value with csv file.I was tried under code

student.rb def self.to_csv attributes = %w{id status email temp_registration_date full_name full_name_kana main_registration_date email2 postal_code1 postal_code2 address1 address2 tel_main tel_sub sex school_type school_name school_name_initial department_name faculty_type graduation_month industry_id industry_most_id occupation_id occupation_most_id desired_work_region_code club_flg school_club_name school_club_type club_name lab_name major_field research_subject_title research_subject_summary interested_companies personal_summary how_known how_known_other mail_magazine_flg}

CSV.generate(headers: true) do |csv|
csv << attributes

all.each do |student|
    
    csv << [student.id,student.status,
 student.sex, if (student.school_type == 1)
    大学
 elsif (student.school_type == 2)
    大学院(修士)
 elsif (student.school_type == 3)
    大学院(博士)
 elsif (student.school_type == 4)
    短大
 elsif (student.school_type == 5)
    専門学校
 elsif (student.school_type == 6)
    高専
 end]
end
end

Aucun commentaire:

Enregistrer un commentaire