我可以以某种方式配置Rails以避免需要向所有文件添加# coding: utf-8吗?还是必须手动将其添加到每个文件?

UPD

为了改善生活,我发现了以下 gem :



它不会解决问题,但是会向每个文件添加magick行。相关主题:Why are all strings ASCII-8BIT after I upgraded to Rails 3?

最佳答案

在Rails应用程序中,您可以在应用程序配置中指定默认的chracter编码。

Application中的config/application.rb类内添加以下代码

看起来像:

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

关于ruby-on-rails - 将 "# coding: utf-8"添加到所有文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7037094/

10-12 07:37
查看更多