again the utf8 issue with rails app

2019-05-24 02:16发布

问题:

Again i stand here and pull my hair..

So im makeing app in Latvian language. So it needs utf8 encoding. I tried to put various configurations in initializers, like:

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

Tried various comments, like:

  • # encoding: utf-8

In my view layout file i have:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

I have my db connection set to utf8, and have no problem with that, actually.

The problem i have is, that i cant just use UTF8 chars in my views. Every time i get this error:

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

Im sure, that my files are encoded in utf8. I dont have a clue what i could do, to make rails app to read utf8 correctly.

回答1:

Ok, so i found a fix, that was good for me, but made a new post, cos this needs more info, i think.. I dont think this is the correct way of doing it, but well.. it fixed all my problems, so maybe this will help for someone else..

is this fix for Rails utf8 issue?