开发者

Encoding::CompatibilityError in rails

开发者 https://www.devze.com 2022-12-15 00:40 出处:网络
<%= link_to \'注销\', :controller => :user, :action => :logout %> this raises Encoding::Compatibility exception, and when i try
<%= link_to '注销', :controller => :user, :action => :logout %>

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>

why ??? i just can't figure out WHY this happends and HOW to fix it. any ideas?? thanks!!! ruby vers开发者_如何学运维ion 1.9, rails 2.3.5


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消