2010-11-03 40 views
1

我在任何地方都有UTF-8,爲什麼Page.last.url.encoding返回「ASCII-8BIT」?即使指定了UTF8,Ruby 1.9字段也會返回ASCII編碼

我的database.yml:

development: 
    adapter: mysql 
    username: root 
    encoding: utf8 
    database: recipebook 

的mysql:

CREATE TABLE `pages` (
    `id` int(11) NOT NULL AUTO_INCREMENT, 
    `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, 
    `user_id` int(11) DEFAULT NULL, 
    `recipe_id` int(11) DEFAULT NULL, 
    `created_at` datetime DEFAULT NULL, 
    `updated_at` datetime DEFAULT NULL, 
    `html` blob, 
    PRIMARY KEY (`id`) 
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 

回答

1

你使用哪種版本的MySQL寶石? 2.8不是紅寶石1.9編碼感知。你可以使用the instructions here來修補它。 Mysql2應該是編碼感知的,但我不確定它在Rails 2上工作(順便說一下,您使用哪個版本的rails?)

+0

關於mysql2的SO問題:http://stackoverflow.com/questions/ 3001243 /紅寶石軌-mysql2-寶石不-有人使用,這-寶石是 - 它穩定 – Teoulas 2010-11-03 19:06:35

相關問題