I know this is the most common problem in the history of programming but I reallu believe I have tried it all now but I still get: incompatible character encodings: UTF-8 and ASCII-8BIT
in my pages#index.html file.
I am running Ruby 1.9.2 and Rails 3.1.1.
This is what I have verified / tested / set:
In database.yml, set encoding: utf8
development: adapter: mysql encoding: utf8 reconnect: false database: kopa_development pool: 5 username: root password: host: localhost
Checked with Notepad++ that the textfile(s) in term is encoded to utf-8
- Checked with mysql query browser that the database is set to utf-8, so are the columns
- I have tried with # coding: utf-8 in the controller related to the view I am trying to look at.
- I have put SET NAMES utf8 in mysql
- I have tried Encoding.default_internal = Encoding::UTF_8 in environment.rb as well as Encoding.default_external = Encoding::UTF_8
- I have config.encoding = "utf-8" in application.rb
- I have Googled
- I have read http://www.joelonsoftware.com/articles/Unicode.html
- I have tried both Notepad++ and RubyMine
- Adding .force_encoding works but is very inconvenient to do
A funny thing is that if I set the index.html.erb to ANSI it will complain that application.html.erb does not have the correct encoding (rather than index.html.erb). I don't know what this means but it makes me think that there is something fishy with the editor.
I remember when using e text editor that there were two things I could set (with reference to encoding) the encoding and something else. That "else" I don't remember what it was though and I don't have e anymore.
Regarding the error-message, do I understand it correctly that the first mentioned means the database encoding and the second the Rails(?) encoding? I have seen the opposite error message as well (ASCII first and UTF-8 after).
Edit: I Googled some more this morning and found there is something wrong with the mysql-gem. The articles were a bit old and I tried the solutions there (such as trying mysql2 & ruby-mysql) with no better luck.
I am all out of ideas. How about you?