我升级到RoR 3.0.1和Ruby升级到1.9.2. 现在我视图中的所有字符串都是ASCII-8BIT?
我相信我的应用程序设置为使用UTF 8
application.rb中
config.encoding = "utf-8"
Run Code Online (Sandbox Code Playgroud)
database.yml的
development:
adapter: mysql
encoding: utf8
Run Code Online (Sandbox Code Playgroud)
我在跑
OS X
RVM rvm 1.0.16
Ruby ruby-1.9.2-p0
Rails 3.0.1
Run Code Online (Sandbox Code Playgroud)
我希望编码是UTF 8而不是ASCII
business.desc.encoding
# ASCII-8BIT
Run Code Online (Sandbox Code Playgroud)
由于1.9.x可以连接不同编码的字符串,我们会看到很多这样的错误.
<p class="description"><%= truncate(business.desc, :length => 17) %></p>
Run Code Online (Sandbox Code Playgroud)
错误
incompatible character encodings: ASCII-8BIT and UTF-8
activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat'
activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat'
actionpack (3.0.1) lib/action_view/template/handlers/erb.rb:14:in `<<'
app/views/browse/businesses.html.erb:15:in `block in _app_views_browse_businesses_html_erb___1616718260917998189_2173630500__1134905695726531092'
app/views/browse/businesses.html.erb:3:in `each'
app/views/browse/businesses.html.erb:3:in `each_with_index'
app/views/browse/businesses.html.erb:3:in `_app_views_browse_businesses_html_erb___1616718260917998189_2173630500__1134905695726531092'
Run Code Online (Sandbox Code Playgroud)
还有其他人有这个问题吗?ruby-1.9.2-p0是否使用正确的版本?
谢谢!