【问题标题】:Very weird encoding error happening only sometimes非常奇怪的编码错误只是有时发生
【发布时间】:2012-06-18 10:35:27
【问题描述】:

我们使用的是 Rails 3.2.3、Ruby 1.9.1 和 HAML。我们有一个 Post 模型,只有在 Internet Explorer 9 中有时才会发生一些非常奇怪的事情。

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):

错误在以下行:

= raw @post.content

Wich 从数据库中返回帖子的内容。注意内容有 HTML 标签。

奇怪的是:

  • 该错误仅在某些使用 IE 9 的机器上显示。(我们无法在使用相同 IE 9 版本的其他机器上重现该错误)
  • 这个错误只是偶尔发生。

我们已经尝试过,但没有运气(同样的错误):

= raw @post.content.force_encoding('utf-8')

有什么见解吗?提前致谢。

更新 经过一些更改,现在错误显示在以下行中:

37:         .social

那行没有什么奇怪的,只有空格(不是制表符)和“.social”字符串。这太疯狂了。

【问题讨论】:

标签: ruby-on-rails encoding haml


【解决方案1】:

好的,终于找到问题了。这是一个

 = link_to "Back" :back

这里解释得更好: Non ascii characters in link_to is causing the app to fail in internet explorer 9 in rails app

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多