0

Im using Active Admin with Rails and I'm exporting all my data in a csv file. It works really well in development, but in production i get this error :

Encoding::UndefinedConversionError (U+00E7 to WINDOWS-1251 in conversion from UTF-8 to WINDOWS-1251)

When I send_data :

date = DateTime.now
csv_title = "O535#{date.year}#{date.strftime('%m')}#{date.strftime('%d')}#{date.strftime('%H')}#{date.strftime('%M')}#{date.strftime('%S')}"

send_data csv.force_encoding('UTF-8'),
          :type => 'text/csv; charset=iso-8859-1; header=present',
          :disposition => "attachment; filename=#{csv_title}.csv"

Has anyone ever met that error ? I tried using csv.encore / csv.force_encoding and many other solutions but it's still working well in development but always crash in production

Thanks a lot

Marlin Pierce
  • 9,931
  • 4
  • 30
  • 52
mharribey
  • 1
  • 3
  • Have you tried this? https://stackoverflow.com/a/11451089/400743 – Bartosz Pietraszko Oct 10 '18 at 17:13
  • Yes I did, but it didn't work. I found a solution by changing the way I used to generate my csv and now it works but I didn't find a solution for the problem above. Thanks for trying to help me ! – mharribey Oct 11 '18 at 18:03

0 Answers0