Rails应用再次出现utf8问题 [英] again the utf8 issue with rails app

查看:149
本文介绍了Rails应用再次出现utf8问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我又站在这里拉头发.

因此我正在用拉脱维亚语制作应用程序.因此,它需要utf8编码. 我试图在初始化器中放入各种配置,例如:

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

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

尝试了各种评论,例如:

Tried various comments, like:

  • #编码:utf-8

在我的视图布局文件中,我有:

In my view layout file i have:

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

我的数据库连接设置为utf8,实际上没有问题.

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

我的问题是,我不能只在视图中使用UTF8字符.每当我收到此错误:

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

我确定我的文件是用utf8编码的.我不知道该怎么做,才能使Rails应用程序正确读取utf8.

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.

推荐答案

好,所以我找到了一个修复程序,对我很好,但是发表了一篇新文章,因为这需要更多信息,我认为..我不认为这是正确的方法,但是好..它解决了我所有的问题,所以也许这对其他人会有帮助.

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..

是否已解决Rails utf8问题?

这篇关于Rails应用再次出现utf8问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆