ruby-on-railsoracle-databaseutf-8

Error: Incompatible character encodings: UTF-8 and ASCII-8BIT


I got the error incompatible character encodings: UTF-8 and ASCII-8BIT, when the view found in the database some characters like: ñ, á, é, etc.

My enviroment is:

I can save this characters in the database, using Toad.

I tried to write this, in the first line of my view:

<% # encoding: utf-8 %>

In enviroment.erb

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

But nothing fixed this.

Please, can someone give some adviced to fixed this.

Thanks.


Solution

  • In the file boot.rb, I added this line:

    ENV['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
    

    Whit this I solved my problem.