我正在使用Rails 3.0.3,并且已将mysql适配器从ruby-mysql更改为mysql2,但现在出现以下错误:mysql2 gem,Rails 3.0.3和“不兼容的字符编码”错误
incompatible character encodings: ASCII-8BIT and UTF-8
我已经阅读过关于此的所有内容,但我无法解决它。
application.rb中:
config.encoding = "utf-8"
的database.yml:
development:
adapter: mysql2
encoding: utf8
database: rails3_development
username: root
password:
host: localhost
宝石:
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (3.0.3)
activemodel (3.0.3)
activerecord (3.0.3)
activeresource (3.0.3)
activesupport (3.0.3)
arel (2.0.7)
bcrypt-ruby (2.1.4)
builder (2.1.2)
erubis (2.6.6)
i18n (0.5.0)
jquery-rails (0.2.6)
mail (2.2.15)
mime-types (1.16)
**mysql2 (0.2.6)
orm_adapter (0.0.4)
paperclip (2.3.8)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.3)
railties (3.0.3)
rake (0.8.7)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.24)
warden (1.0.3)
will_paginate (3.0.pre2)
对于其他搜索者:如果您使用mysql2和blob数据类型,它将始终返回二进制。只需将您的blob字段更改为“文本”数据类型即可。它会保持编码。 – 2012-11-06 13:57:47