Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 Encoding::CompatibilityError

I am working on a rails app that submits a french translation via ajax and for some reason I keep getting the following error in the log:

Encoding::CompatibilityError incompatible character encodings: UTF-8 and ASCII-8BIT

Does anyone know how to fix this?

FIX:This works on the WEBrick sever

Place # encode: UTF-8 at the top of each file you want to work with different chars

I can't get this to work on a rails server with Thin... anyone else run into this?

like image 644
dennismonsewicz Avatar asked Nov 04 '10 01:11

dennismonsewicz


1 Answers

https://rails.lighthouseapp.com/projects/8994/tickets/4336-ruby19-submitted-string-form-parameters-with-non-ascii-characters-cause-encoding-errors

the above link fixed my problem.

Specifically myString.force_encoding('UTF-8') on the string before sending it for translation.

Placed the sample code in the Application_controller.rb file and all is well

like image 103
dennismonsewicz Avatar answered Sep 28 '22 16:09

dennismonsewicz