在rails中编码:: CompatibilityError [英] Encoding::CompatibilityError in rails
本文介绍了在rails中编码:: CompatibilityError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%= link_to '注销', :controller => :user, :action => :logout %>
这会引发Encoding :: Compatibility异常,当我尝试
this raises Encoding::Compatibility exception, and when i try
<%= link_to '注销'.force_encoding('utf-8'), :controller => :user, :action => :logout %>
这也没有帮助。但这个工作
this didn't help, either. but this works
<a href="<%= url_for :controller => :user, :action => :logout>">注销</a>
为什么?我只是不知道为什么这发生了,如何解决它。有任何想法吗??谢谢!!!
ruby版本1.9,rails 2.3.5
why ??? i just can't figure out WHY this happends and HOW to fix it. any ideas?? thanks!!! ruby version 1.9, rails 2.3.5
推荐答案
之前我有类似的错误,原来文件本身包含代码不使用UTF8编码:(所以你最好检查你正在使用的编辑器,因为它可能没有使用UTF8编码的文件。
I got similar errors before and it turned out that the file itself that contains the code is not using UTF8 encoding :(, so you'd better check the editor you are using as it might not be using UTF8 encoded files.
这篇关于在rails中编码:: CompatibilityError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文