【发布时间】:2013-11-19 15:38:54
【问题描述】:
我在生产中遇到不兼容的字符编码错误。我试图在本地复制它,但没有运气。这是错误信息:
A ActionView::Template::Error occurred in controller_name#action_name:
incompatible character encodings: UTF-8 and ASCII-8BIT
activesupport (3.0.5) lib/active_support/core_ext/string/output_safety.rb:80:in `concat'
config.encoding 已在 application.rb 中设置为“utf-8”。令我困惑的是,问题仅在乘客重新启动前后持续一段时间,并在一段时间后消失。对异常回溯的进一步调试给了我这个:
activesupport (3.0.5) lib/active_support/core_ext/string/output_safety.rb:80:in `concat'
activesupport (3.0.5) lib/active_support/core_ext/string/output_safety.rb:80:in `concat'
actionpack (3.0.5) lib/action_view/template/handlers/erb.rb:14:in `<<'
app/views/web/controller_name/action_name.erb:98
<%currentUrl = request.url%>
Line 98: <a href="<%= raw currentUrl %>" id="xyz">
“ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT)”中提到ActionDispatch::Request 可能会导致问题,但我不知道问题如何在一段时间后自行解决!
【问题讨论】:
标签: ruby-on-rails ruby utf-8 character-encoding passenger