Ruby 1.9抛出JavaScript编码错误 [英] Ruby 1.9 throwing javascript encoding error
本文介绍了Ruby 1.9抛出JavaScript编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我将Ruby更新为1.9.2,然后执行以下操作:
So, I updated my Ruby to 1.9.2, followed this:
- 确保application.rb文件中有"config.encoding ="utf-8"".
- 确保您使用的是"mysql2" gem
- 在rake文件顶部放置#编码:utf-8".
- 在"Starter :: Application.initialize!"之上在environment.rb文件中添加以下两行:
- Encoding.default_external =编码:: UTF_8
- Encoding.default_internal =编码:: UTF_8
- Make sure 'config.encoding = "utf-8"' is there in application.rb file.
- Make sure you are using 'mysql2' gem
- Putting '# encoding: utf-8' on top of rake file.
- Above 'Starter::Application.initialize!' line in environment.rb file, add following two lines:
- Encoding.default_external = Encoding::UTF_8
- Encoding.default_internal = Encoding::UTF_8
现在我所有的Ruby代码都可以正常工作,但是我的asset/javascript/application.js仅使用以下代码加载:
and now all my Ruby code is working right, but my assets/javascript/application.js is loaded only with this code:
throw Error("Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8")
我如何定义资产编码?
ps .:我尚未尝试进行预编译,这是在开发模式下发生的
ps.: i didn't try to precompile yet, this is happening on development mode
推荐答案
Read the answer to this question. Sounds like it's the same issue you're looking at. It sounds like the solution is to open the
.js
file with a text editor and save it as UTF-8 encoding.这篇关于Ruby 1.9抛出JavaScript编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文