将项目部署至另一服务器后,报错 (用 scaffold 建立的,index 的页面都正常显示,只有点击 new 页面会报此错误),报错信息如下所示:
ActionView::Template::Error (Your template was not saved as valid UTF-8. Please either specify UTF-8 as the encoding for your template in your text editor, or mark the template with its encoding by inserting the following as the first line of the template:
# encoding: <name of correct encoding>.
The source of your template was:
3m�*��w��_v߃��p�#3ʱ���>�{nS�
���2��ȩWK�vJ|Dtt��TM�U�������T����3�a�D���ĉ�?p��m�S�,�:�iK,L�p;��'F�ex���<
��v�>/���%��_I�z�ö������v��Jj�
�zWE6��n$��ݴ��?u�n��R~���ȁ�=[r��k��$��f�o�Ӿ%p�d�uh69���MΏ��9�Wܦ^�X���¬cZ~o���*�����V*�B��t�(一堆类似这样的乱码)
百度后发现一个解决此问题的帖子:
2.在 application.rb 文件里加上 config.encoding = "utf-8"