Ruby on rails rails编码问题=(
我在ruby 1.9.2中使用rails 2.3.9,当我试图用一些俄语字母更新我的模型时,unicorn日志中出现了错误:Ruby on rails rails编码问题=(,ruby-on-rails,Ruby On Rails,我在ruby 1.9.2中使用rails 2.3.9,当我试图用一些俄语字母更新我的模型时,unicorn日志中出现了错误: Error during failsafe response: incompatible character encodings: UTF-8 and ASCII-8BIT Read error: #<NoMethodError: undefined method `[]' for nil:NilClass> 故障保护响应期间出错:不兼容的字符编码:UTF-
Error during failsafe response: incompatible character encodings: UTF-8 and ASCII-8BIT
Read error: #<NoMethodError: undefined method `[]' for nil:NilClass>
故障保护响应期间出错:不兼容的字符编码:UTF-8和ASCII-8BIT
读取错误:#您应该确保编辑器以UTF-8格式保存文件。ASCII afaik是任何字符集的第一部分。这应该是当您省略俄文字符时不会出现任何错误的原因。我在这里用脚本回答了这个问题 你需要
# coding: UTF-8
在文件的顶部,使用ruby 1.9。如果这没有帮助,可能是您的外部依赖项,例如DB。您可以使用gem“俄语”(gem基于l18n)
在模型中(而不是俄语字母):
俄语::翻译(:一些单词)
在配置文件中(必须用UTF-8编码):
ru:
一些单词:“这是俄语字母串”rbdev@Ubuntu-1004-lucid-64-minimal:~/sites/avantage/app/views/admin/categories$file-i edit.html.haml edit.html.haml:text/plain;charset=us ascii