【发布时间】:2011-02-07 10:45:41
【问题描述】:
我使用的是Rails 3.0.3,并且我已经将mysql适配器从ruby-mysql改为mysql2,但是现在出现以下错误:
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 字段更改为“文本”数据类型。它将保持编码。
标签: mysql ruby-on-rails-3 character-encoding